Loggers

Loggers which implement log_line(stream, data) which are used to send log data to a stream.

class clog.loggers.FileLogger

Implementation that logs to local files under a directory

class clog.loggers.GZipFileLogger(day=None)

Implementation of a logger that logs to local gzipped files.

class clog.loggers.MockLogger

Mock implementation for testing

class clog.loggers.MonkLogger(client_id, host=None, port=None, stream_backend_map={})

Wrapper around MonkProducer

class clog.loggers.ScribeLogger(host, port, retry_interval, report_status=None, logging_timeout=None, stream_backend_map={})

Implementation that logs to a scribe server. If errors are encountered, drop lines and retry occasionally.

Parameters:
  • host – hostname of the scribe server
  • port – port number of the scribe server
  • retry_interval – number of seconds to wait between retries
  • report_status – a function report_status(is_error, msg) which is called to print out errors and status messages. The first argument indicates whether what is being printed is an error or not, and the second argument is the actual message.
  • logging_timeout – milliseconds to time out scribe logging; “0” means blocking (no timeout)
log_line(stream, line)

Log a single line. It should not include any newline characters. If the line size is over 50 MB, an exception raises and the line will be dropped. If the line size is over 5 MB, a message consisting origin stream information will be recorded at WHO_CLOG_LARGE_LINE_STREAM (in json format).

class clog.loggers.StdoutLogger

Implementation that logs to stdout with stream name as a prefix.

clog.loggers.get_default_reporter(use_syslog=None)

Returns the default reporter based on the value of the argument

Parameters:report_to_syslog – Whether to use syslog or stderr. Defaults to the value of config.scribe_errors_to_syslog