logging: Make our own Formatter class.

This doesn't yet do much, but it gives us a suitable place to
add code to customize how log messages are displayed, beyond what
a format string passed to the default formatter can do.
This commit is contained in:
Greg Price
2017-09-27 14:40:38 -07:00
parent e0a5e6fade
commit 0163920577
3 changed files with 12 additions and 3 deletions

View File

@@ -125,6 +125,17 @@ def skip_site_packages_logs(record):
return False
return True
class ZulipFormatter(logging.Formatter):
_fmt = '%(asctime)s %(levelname)-8s %(message)s'
def __init__(self):
# type: () -> None
super().__init__(fmt=self._fmt)
def format(self, record):
# type: (logging.LogRecord) -> str
return super().format(record)
def create_logger(name, log_file, log_level, log_format="%(asctime)s %(levelname)-8s %(message)s"):
# type: (str, str, str, str) -> Logger
"""Creates a named logger for use in logging content to a certain