|
@ -8,6 +8,7 @@ import logging.handlers |
|
|
from .sender import LogzioSender |
|
|
from .sender import LogzioSender |
|
|
from .exceptions import LogzioException |
|
|
from .exceptions import LogzioException |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ExtraFieldsLogFilter(logging.Filter): |
|
|
class ExtraFieldsLogFilter(logging.Filter): |
|
|
|
|
|
|
|
|
def __init__(self, extra: dict, *args, **kwargs): |
|
|
def __init__(self, extra: dict, *args, **kwargs): |
|
@ -18,6 +19,7 @@ class ExtraFieldsLogFilter(logging.Filter): |
|
|
record.__dict__.update(self.extra) |
|
|
record.__dict__.update(self.extra) |
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LogzioHandler(logging.Handler): |
|
|
class LogzioHandler(logging.Handler): |
|
|
|
|
|
|
|
|
def __init__(self, |
|
|
def __init__(self, |
|
@ -104,7 +106,7 @@ pip install 'logzio-python-handler[opentelemetry-logging]'""") |
|
|
def format_message(self, message): |
|
|
def format_message(self, message): |
|
|
now = datetime.datetime.utcnow() |
|
|
now = datetime.datetime.utcnow() |
|
|
timestamp = now.strftime('%Y-%m-%dT%H:%M:%S') + \ |
|
|
timestamp = now.strftime('%Y-%m-%dT%H:%M:%S') + \ |
|
|
'.%03d' % (now.microsecond / 1000) + 'Z' |
|
|
|
|
|
|
|
|
'.%03d' % (now.microsecond / 1000) + 'Z' |
|
|
|
|
|
|
|
|
return_json = { |
|
|
return_json = { |
|
|
'logger': message.name, |
|
|
'logger': message.name, |
|
|