Navigation Menu

Skip to content
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

Added custom formatter support #1

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions ScribeHandler.py
Expand Up @@ -88,6 +88,18 @@ def __setattr__(self, var, val):




def emit(self, record): def emit(self, record):
"""
Emit a record.

If a formatter is specified, it is used to format the record.
The record is then logged to Scribe with a trailing newline.
"""
# apply formatting to the record.
msg = self.format(record)
# for backwards-compatibility, do not add in a line break if it
# is already being manually added into each record.
if not msg.startswith('\n') or msg.endswith('\n'):
msg += '\n'


if (self.client is None) or (self.transport is None): if (self.client is None) or (self.transport is None):
raise ScribeTransportError('No transport defined') raise ScribeTransportError('No transport defined')
Expand All @@ -107,8 +119,7 @@ def emit(self, record):
'hostname' : socket.gethostname(), 'hostname' : socket.gethostname(),
} }


log_entry = scribe.LogEntry(category=category, log_entry = scribe.LogEntry(category=category, message=msg)
message=record.getMessage())


try: try:
self.transport.open() self.transport.open()
Expand Down