Skip to content

logger

Logging to both file and terminal

CONFIG: ServerConfig = ServerConfig() module-attribute

This singleton loads the config from a hierarchy of sources (see customise_sources) and makes it importable in the server code.

CONSOLE_FORMATTER = DefaultFormatter('%(levelprefix)s [%(name)s] %(message)s') module-attribute

CONSOLE_HANDLER = logging.StreamHandler(sys.stdout) module-attribute

FILE_FORMATTER = logging.Formatter('[%(levelname)-8s %(asctime)s %(filename)s:%(lineno)d][%(name)s] %(message)s', '%d-%m-%Y %H:%M:%S') module-attribute

FILE_HANDLER = logging.handlers.RotatingFileHandler(LOGS_DIR.joinpath('optimade.log'), maxBytes=1000000, backupCount=5) module-attribute

LOGGER = logging.getLogger('optimade') module-attribute

LOGS_DIR = CONFIG.log_dir module-attribute