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:
commit
a1f8690978
@ -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)
|
||||
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user