cambrian.utils.logger

Provides a custom logger object.

Should be used like the following:

from cambrian.utils.logger import get_logger

get_logger().fatal("Fatal")
get_logger().error("Error")
get_logger().warn("Warning")
get_logger().info("Information")
get_logger().debug("Debug")

Classes

MjCambrianFileHandler

A file handler which creates the directory if it doesn't exist.

MjCambrianTqdmStreamHandler

A handler that uses tqdm.write to log messages.

MjCambrianLoggerMaxLevelFilter

This filter sets a maximum level.

MjCambrianOnceFilter

This filter allows a message to be logged only once.

Module Contents

class MjCambrianFileHandler(filename, *args, **kwargs)[source]

Bases: logging.FileHandler

A file handler which creates the directory if it doesn’t exist.

class MjCambrianTqdmStreamHandler(stream=None)[source]

Bases: logging.StreamHandler

A handler that uses tqdm.write to log messages.

emit(record)[source]

Emit a record.

If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.

class MjCambrianLoggerMaxLevelFilter(max_level)[source]

Bases: logging.Filter

This filter sets a maximum level.

filter(record)[source]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

class MjCambrianOnceFilter[source]

Bases: logging.Filter

This filter allows a message to be logged only once.

filter(record)[source]

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.