pgfinder.logs.logs

Standardise logging.

Attributes

start

LOG_CONFIG

LOG_FORMATTER

LOG_ERROR_FORMATTER

LOGGER_NAME

Functions

setup_logger(→ logging.Logger)

Setup a standard logger.

Module Contents

pgfinder.logs.logs.start
pgfinder.logs.logs.LOG_CONFIG = None
pgfinder.logs.logs.LOG_FORMATTER
pgfinder.logs.logs.LOG_ERROR_FORMATTER
pgfinder.logs.logs.LOGGER_NAME = 'pgfinder'
pgfinder.logs.logs.setup_logger(log_name: str = LOGGER_NAME) logging.Logger[source]

Setup a standard logger.

The logger for the module is initialised when the module is loaded (as this functions is called from __init__.py). This creates two stream handlers, one for general output and one for errors which are formatted differently (there is greater information in the error formatter). To use in modules import the ‘LOGGER_NAME’ and create a logger as shown in the Examples, it will inherit the formatting and direction of messages to the correct stream.

Parameters:

log_name (str) – Name under which logging information occurs.

Returns:

Logger object.

Return type:

logging.Logger

Examples

To use the logger in (sub-)modules have the following.

import logging from topostats.logs.logs import LOGGER_NAME

LOGGER = logging.getLogger(LOGGER_NAME)

LOGGER.info(‘This is a log message.’)