Logging

Module for logging.

author:Mischa Kolbe <mik@dneg.com>
credits:Steven Bills, Mischa Kolbe
class logger.NullHandler(level=0)[source]

Basic custom logging handler.

emit(record)[source]

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.

logger.clear_handlers()[source]

Reset handlers of logger.

Note

This prevents creating multiple handler copies when using reload(logger).

logger.setup_file_handler(file_path, max_bytes=104857600, level=20)[source]

Creates a rotating file handler for logging.

Default level is info.

Parameters:
  • file_path (str) – Path where to save the log to.
  • max_bytes (int) – Maximum size of output file.
  • level (int) – Desired logging level. Default is logging.INFO.

max_bytes: x << y Returns x with the bits shifted to the left by y places. 100 << 20 === 100 * 2 ** 20

logger.setup_stream_handler(level=20)[source]

Create a stream handler for logging.

Note

Logging levels are: DEBUG, INFO, WARN, ERROR, CRITICAL

Parameters:level (int) – Desired logging level. Default is logging.INFO.