|
|
|
@ -36,17 +36,21 @@ file_formatter = LogFormatterForFiles(fmt="%(asctime)22s | %(levelname)8s | %(na |
|
|
|
|
|
|
|
|
|
|
|
class LogFormatterForConsole(logging.Formatter): |
|
|
|
class LogFormatterForConsole(logging.Formatter): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def formatTime(self, record, datefmt=None): |
|
|
|
|
|
|
|
t = record.relativeCreated / 1000 |
|
|
|
|
|
|
|
return f"{t:6.2f}" |
|
|
|
|
|
|
|
|
|
|
|
def format(self, record): |
|
|
|
def format(self, record): |
|
|
|
|
|
|
|
record = copy.copy(record) # avoid mutating arg |
|
|
|
record = _shorten_name_of_logrecord(record) |
|
|
|
record = _shorten_name_of_logrecord(record) |
|
|
|
|
|
|
|
if shortcut := getattr(record, 'custom_shortcut', None): |
|
|
|
|
|
|
|
record.name = f"{shortcut}/{record.name}" |
|
|
|
text = super().format(record) |
|
|
|
text = super().format(record) |
|
|
|
shortcut = getattr(record, 'custom_shortcut', None) |
|
|
|
|
|
|
|
if shortcut: |
|
|
|
|
|
|
|
text = text[:1] + f"/{shortcut}" + text[1:] |
|
|
|
|
|
|
|
return text |
|
|
|
return text |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# try to make console log lines short... no timestamp, short levelname, no "electrum." |
|
|
|
# try to make console log lines short... no timestamp, short levelname, no "electrum." |
|
|
|
console_formatter = LogFormatterForConsole(fmt="%(levelname).1s | %(name)s | %(message)s") |
|
|
|
console_formatter = LogFormatterForConsole(fmt="%(asctime)s | %(levelname).1s | %(name)s | %(message)s") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _shorten_name_of_logrecord(record: logging.LogRecord) -> logging.LogRecord: |
|
|
|
def _shorten_name_of_logrecord(record: logging.LogRecord) -> logging.LogRecord: |
|
|
|
|