This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2020-02-24 12:16:05 +00:00
|
|
|
"""logging helpers"""
|
2020-09-21 17:31:01 +00:00
|
|
|
from logging import Logger
|
2020-02-24 12:16:05 +00:00
|
|
|
from os import getpid
|
2020-09-21 17:31:01 +00:00
|
|
|
from typing import Callable
|
2020-02-24 12:16:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
# pylint: disable=unused-argument
|
2020-09-21 17:31:01 +00:00
|
|
|
def add_process_id(logger: Logger, method_name: str, event_dict):
|
2020-02-24 12:16:05 +00:00
|
|
|
"""Add the current process ID"""
|
2020-02-24 13:10:58 +00:00
|
|
|
event_dict["pid"] = getpid()
|
2020-02-24 12:16:05 +00:00
|
|
|
return event_dict
|
2020-09-21 17:31:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
def add_common_fields(environment: str) -> Callable:
|
|
|
|
"""Add a common field to easily search for passbook logs"""
|
|
|
|
|
|
|
|
def add_common_field(logger: Logger, method_name: str, event_dict):
|
|
|
|
"""Add a common field to easily search for passbook logs"""
|
|
|
|
event_dict["app"] = "passbook"
|
|
|
|
event_dict["app_environment"] = environment
|
|
|
|
return event_dict
|
|
|
|
|
|
|
|
return add_common_field
|