mirror of https://github.com/zulip/zulip.git
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:
parent
e0a5e6fade
commit
0163920577
|
@ -204,8 +204,6 @@ def build_custom_checkers(by_lang):
|
||||||
'exclude_line': set([
|
'exclude_line': set([
|
||||||
('zerver/views/users.py',
|
('zerver/views/users.py',
|
||||||
"return json_error(_(\"Email '%(email)s' not allowed for realm '%(realm)s'\") %"),
|
"return json_error(_(\"Email '%(email)s' not allowed for realm '%(realm)s'\") %"),
|
||||||
('zproject/settings.py',
|
|
||||||
"'format': '%(asctime)s %(levelname)-8s %(message)s'"),
|
|
||||||
('static/templates/settings/bot-settings.handlebars',
|
('static/templates/settings/bot-settings.handlebars',
|
||||||
"'https://hostname.example.com/bots/followup'"),
|
"'https://hostname.example.com/bots/followup'"),
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -125,6 +125,17 @@ def skip_site_packages_logs(record):
|
||||||
return False
|
return False
|
||||||
return True
|
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"):
|
def create_logger(name, log_file, log_level, log_format="%(asctime)s %(levelname)-8s %(message)s"):
|
||||||
# type: (str, str, str, str) -> Logger
|
# type: (str, str, str, str) -> Logger
|
||||||
"""Creates a named logger for use in logging content to a certain
|
"""Creates a named logger for use in logging content to a certain
|
||||||
|
|
|
@ -1051,7 +1051,7 @@ LOGGING = {
|
||||||
'disable_existing_loggers': False,
|
'disable_existing_loggers': False,
|
||||||
'formatters': {
|
'formatters': {
|
||||||
'default': {
|
'default': {
|
||||||
'format': '%(asctime)s %(levelname)-8s %(message)s'
|
'()': 'zerver.lib.logging_util.ZulipFormatter',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'filters': {
|
'filters': {
|
||||||
|
|
Loading…
Reference in New Issue