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.

exception clog.loggers.LogLineIsTooLongError
class clog.loggers.MockLogger

Mock implementation for testing

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

Wrapper around MonkProducer

exception clog.loggers.ScribeIsNotForkSafeError
class clog.loggers.ScribeLogger(host, port, retry_interval, report_status=None, logging_timeout=None)

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

  • 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.ScribeMonkLogger(config, scribe_logger, monk_logger, preferred_backend_map={})

The ScribeMonkLogger is a wrapper around both the ScribeLogger and the MonkLogger. The actuall logger being used will depend on the preferred_backend and preferred_backend_map.

class clog.loggers.StdoutLogger

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


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
clog.loggers.report_to_syslog(is_error, msg)

Report errors into Syslog.

Use Syslog with UDP in order not to be forced to write to a unix socket, useful if yelp-clog is run inside docker containers with Syslog running on the actual host.

Syslogs prepends ‘ident: ‘ to messages with an identifier. This function uses clog as identifier.