root: add process ID to logging output

This commit is contained in:
Jens Langhammer 2020-02-24 13:16:05 +01:00
parent 4daa70c894
commit 238b489e07
3 changed files with 17 additions and 0 deletions

6
.isort.cfg Normal file
View File

@ -0,0 +1,6 @@
[settings]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88

9
passbook/lib/logging.py Normal file
View File

@ -0,0 +1,9 @@
"""logging helpers"""
from os import getpid
# pylint: disable=unused-argument
def add_process_id(logger, method_name, event_dict):
"""Add the current process ID"""
event_dict["pdi"] = getpid()
return event_dict

View File

@ -22,6 +22,7 @@ from sentry_sdk.integrations.django import DjangoIntegration
from passbook import __version__
from passbook.lib.config import CONFIG
from passbook.lib.logging import add_process_id
from passbook.lib.sentry import before_send
LOGGER = structlog.get_logger()
@ -279,6 +280,7 @@ structlog.configure_once(
processors=[
structlog.stdlib.add_log_level,
structlog.stdlib.add_logger_name,
add_process_id,
structlog.stdlib.PositionalArgumentsFormatter(),
structlog.processors.TimeStamper(),
structlog.processors.StackInfoRenderer(),