mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
22 lines
541 B
Python
22 lines
541 B
Python
import logging
|
|
import uuid
|
|
|
|
|
|
class LoggingMixin:
|
|
|
|
logging_group = None
|
|
|
|
logging_name = None
|
|
|
|
def renew_logging_group(self):
|
|
self.logging_group = uuid.uuid4()
|
|
|
|
def log(self, level, message, **kwargs):
|
|
if self.logging_name:
|
|
logger = logging.getLogger(self.logging_name)
|
|
else:
|
|
name = ".".join([self.__class__.__module__, self.__class__.__name__])
|
|
logger = logging.getLogger(name)
|
|
|
|
getattr(logger, level)(message, extra={"group": self.logging_group}, **kwargs)
|