Handlers

logging.Handler objects which can be used to send standard python logging to a scribe stream.

class clog.handlers.ScribeHandler(host, port, stream, retry_interval=0)

Handler for sending python standard logging messages to a scribe stream.

import clog.handlers, logging
log = logging.getLogger(name)
log.addHandler(clog.handlers.ScribeHandler('localhost', 3600, 'stream', retry_interval=3))
Parameters:
  • host – hostname of scribe server
  • port – port number of scribe server
  • stream – name of the scribe stream logs will be sent to
  • retry_interval – default 0, number of seconds to wait between retries
emit(record)

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

class clog.handlers.CLogHandler(stream, logger=None)

Deprecated since version 0.1.6.

Warning

Use ScribeHandler if you want to log to scribe, or a logging.handlers.FileHandler to log to a local file.

Handler for the standard logging library that logs to clog.

emit(record)

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

clog.handlers.add_logger_to_scribe(logger, log_level=20, fmt='%(process)s\t%(asctime)s\t%(name)-12s %(levelname)-8s: %(message)s', clogger_object=None)

Sets up a logger to log to scribe.

By default, messages at the INFO level and higher will go to scribe.

Deprecated since version 0.1.6.

Warning

This function is deprecated in favor of using clog.log_line() or ScribeHandler directly.

Parameters:
  • logger – A logging.Logger instance
  • log_level – The level to log at
  • clogger_object – for use in testing
clog.handlers.get_scribed_logger(log_name, *args, **kwargs)

Get/create a logger and adds it to scribe.

Deprecated since version 0.1.6.

Warning

This function is deprecated in favor of using clog.log_line() directly.

Parameters:
  • log_name – name of log to write to using logging.getLogger
  • kwargs (args,) – passed to add_logger_to_scribe
Returns:

a logging.Logger