1
0
forked from clan/clan-core

Merge pull request 'Improved error messages in clan_cli' (#746) from Qubasa-main into main

This commit is contained in:
clan-bot 2024-01-19 13:13:46 +00:00
commit a1f8690978
2 changed files with 9 additions and 7 deletions

View File

@ -139,11 +139,10 @@ def main() -> None:
sys.exit(1)
if isinstance(e, ClanCmdError):
if e.cmd.msg:
print(e.cmd.msg, file=sys.stderr)
else:
print(e, file=sys.stderr)
elif isinstance(e, ClanError):
print(e, file=sys.stderr)
log.error(e.cmd.msg)
sys.exit(1)
log.error(e)
sys.exit(1)

View File

@ -22,7 +22,7 @@ def get_formatter(color: str) -> Callable[[logging.LogRecord, bool], logging.For
return logging.Formatter(f"{color}%(levelname)s{reset}: %(message)s")
return logging.Formatter(
f"{color}%(levelname)s{reset}: %(message)s\n {filepath}:%(lineno)d::%(funcName)s\n"
f"{color}%(levelname)s{reset}: %(message)s\n {filepath}:%(lineno)d::%(funcName)s\n"
)
return myformatter
@ -39,7 +39,10 @@ FORMATTER = {
class CustomFormatter(logging.Formatter):
def format(self, record: logging.LogRecord) -> str:
return FORMATTER[record.levelno](record, True).format(record)
if record.levelno == logging.DEBUG:
return FORMATTER[record.levelno](record, True).format(record)
else:
return FORMATTER[record.levelno](record, False).format(record)
class ThreadFormatter(logging.Formatter):