edflow.custom_logging module

Summary

Classes:

LogSingleton

TqdmHandler

Functions:

fix_abseil

get_default_logger

get_logger

Creates a logger, which shares its output directory with all other loggers.

init_project

Must be called at the very beginning of a script.

set_global_stdout_level

use_project

Must be called at the very beginning of a script.

Reference

class edflow.custom_logging.TqdmHandler(pos=4)[source]

Bases: logging.StreamHandler

__init__(pos=4)[source]

Initialize the handler.

If stream is not specified, sys.stderr is used.

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 edflow.custom_logging.LogSingleton(out_base_dir=None, level=20, write_pos=4)[source]

Bases: object

exists = False
default = 'root'
__init__(out_base_dir=None, level=20, write_pos=4)[source]

Initialize self. See help(type(self)) for accurate signature.

set_default(which)[source]
get(name, which=None)[source]

Create logger, set level.

Parameters
  • name (str or object) – Name of the logger. If not a string, the name of the given object class is used.

  • which (str) – subdirectory in the project folder.

edflow.custom_logging.set_global_stdout_level(level='info')[source]
edflow.custom_logging.get_default_logger()[source]
edflow.custom_logging.fix_abseil()[source]
edflow.custom_logging.init_project(base_dir, code_root='.', postfix=None)[source]

Must be called at the very beginning of a script.

edflow.custom_logging.use_project(project_dir, postfix=None)[source]

Must be called at the very beginning of a script.

edflow.custom_logging.get_logger(name, which=None, level='info')[source]

Creates a logger, which shares its output directory with all other loggers.

Parameters
  • name (str) – Name of the logger.

  • which (str) – Any subdirectory of the project.