mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
logging: Add option to show the PID in each log message.
This commit is contained in:
@@ -177,11 +177,17 @@ class ZulipFormatter(logging.Formatter):
|
||||
# Used in the base implementation. Default uses `,`.
|
||||
default_msec_format = '%s.%03d'
|
||||
|
||||
_fmt = '%(asctime)s %(zulip_level_abbrev)-4s [%(zulip_origin)s] %(message)s'
|
||||
|
||||
def __init__(self):
|
||||
# type: () -> None
|
||||
super().__init__(fmt=self._fmt)
|
||||
super().__init__(fmt=self._compute_fmt())
|
||||
|
||||
def _compute_fmt(self):
|
||||
# type: () -> str
|
||||
pieces = ['%(asctime)s', '%(zulip_level_abbrev)-4s']
|
||||
if settings.LOGGING_SHOW_PID:
|
||||
pieces.append('pid:%(process)d')
|
||||
pieces.extend(['[%(zulip_origin)s]', '%(message)s'])
|
||||
return ' '.join(pieces)
|
||||
|
||||
def format(self, record):
|
||||
# type: (logging.LogRecord) -> str
|
||||
|
||||
@@ -173,6 +173,11 @@ FEEDBACK_EMAIL = ZULIP_ADMINISTRATOR
|
||||
# mysterious log message, but a little verbose.
|
||||
#LOGGING_SHOW_MODULE = False
|
||||
|
||||
# If True, each log message in the server logs will identify the
|
||||
# process ID. Useful for correlating logs with information from
|
||||
# system-level monitoring tools.
|
||||
#LOGGING_SHOW_PID = False
|
||||
|
||||
# Controls whether or not Zulip will provide inline image preview when
|
||||
# a link to an image is referenced in a message. Note: this feature
|
||||
# can also be disabled in a realm's organization settings.
|
||||
|
||||
@@ -135,6 +135,7 @@ DEFAULT_SETTINGS = {
|
||||
'ERROR_REPORTING': True,
|
||||
'BROWSER_ERROR_REPORTING': False,
|
||||
'LOGGING_SHOW_MODULE': False,
|
||||
'LOGGING_SHOW_PID': False,
|
||||
|
||||
# File uploads and avatars
|
||||
'DEFAULT_AVATAR_URI': '/static/images/default-avatar.png',
|
||||
|
||||
Reference in New Issue
Block a user