-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use a custom log formatter #381
Comments
I noticed this same issue. Any sort of timeline available for a fix? |
I think the problem is in the Line 89 in f67253a
It is not taking into account the Here's how you could grab it out though: DEFAULT_ATTRS = (
'args',
'asctime',
'created',
'exc_info',
'exc_text',
'filename',
'funcName',
'levelname',
'levelno',
'lineno',
'module',
'msecs',
'message',
'msg',
'name',
'pathname',
'process',
'processName',
'relativeCreated',
'stack_info',
'thread',
'threadName',
)
def get_extra_from_record(self, record):
"""
Returns the dict that was passed in as extra data
e.g. logging,info('Log log log', extra={'extra_code': 'ABC123'})
"""
return {
attr: record.__dict__[attr]
for attr in record.__dict__
if attr not in DEFAULT_ATTRS
} You could extend from the class RollbarWithExtraHandler(RollbarHandler):
def emit(self, record):
record.extra_data = self._get_extra_from_record(record)
super().emit(record)
def _get_extra_from_record(self, record):
"""
Returns the dict that was passed in as extra data
e.g. logging,info('Log log log', extra={'extra_code': 'ABC123'})
"""
return {
attr: record.__dict__[attr]
for attr in record.__dict__
if attr not in DEFAULT_ATTRS
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Formatter
Handler
Using:
Expectation:
The correct formatted message shows up in rollbar.
currently shows
"This is a test"
Instead of
"This is a test <MyObject.__repr__(...)>"
The text was updated successfully, but these errors were encountered: