2016-02-27 20:18:50 +00:00
|
|
|
import logging
|
2020-11-18 13:23:30 +01:00
|
|
|
import uuid
|
2016-02-27 20:18:50 +00:00
|
|
|
|
|
|
|
|
|
2020-11-18 13:23:30 +01:00
|
|
|
class LoggingMixin:
|
2023-05-19 15:23:11 -07:00
|
|
|
def __init__(self) -> None:
|
|
|
|
|
self.renew_logging_group()
|
2021-02-05 01:10:29 +01:00
|
|
|
|
2020-11-18 13:23:30 +01:00
|
|
|
def renew_logging_group(self):
|
2023-05-19 15:23:11 -07:00
|
|
|
"""
|
|
|
|
|
Creates a new UUID to group subsequent log calls together with
|
|
|
|
|
the extra data named group
|
|
|
|
|
"""
|
2020-11-18 13:23:30 +01:00
|
|
|
self.logging_group = uuid.uuid4()
|
2023-05-19 15:23:11 -07:00
|
|
|
self.log = logging.LoggerAdapter(
|
|
|
|
|
logging.getLogger(self.logging_name),
|
|
|
|
|
extra={"group": self.logging_group},
|
|
|
|
|
)
|