mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-13 18:17:02 +01:00
updated logging, logging for the mail consumer to see whats happening
This commit is contained in:
parent
1b0233418b
commit
8908bc259e
10 changed files with 214 additions and 152 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import uuid
|
||||
|
||||
|
||||
class PaperlessHandler(logging.Handler):
|
||||
|
|
@ -13,3 +14,19 @@ class PaperlessHandler(logging.Handler):
|
|||
kwargs["group"] = record.group
|
||||
|
||||
Log.objects.create(**kwargs)
|
||||
|
||||
|
||||
class LoggingMixin:
|
||||
|
||||
logging_group = None
|
||||
|
||||
def renew_logging_group(self):
|
||||
self.logging_group = uuid.uuid4()
|
||||
|
||||
def log(self, level, message):
|
||||
target = ".".join([self.__class__.__module__, self.__class__.__name__])
|
||||
logger = logging.getLogger(target)
|
||||
|
||||
getattr(logger, level)(message, extra={
|
||||
"group": self.logging_group
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue