Skip to content

autocorpus

autocorpus ¤

AutoCorpus package.

Attributes¤

logger = create_logger() module-attribute ¤

The logger for the Auto-CORPus module and command-line program.

Functions¤

add_file_logger(file_path) ¤

Add a log handler to write log messages to file.

Source code in autocorpus/__init__.py
24
25
26
27
28
29
def add_file_logger(file_path):
    """Add a log handler to write log messages to file."""
    # same format as used for console
    fh = logging.FileHandler(file_path)
    fh.setFormatter(_log_formatter)
    logger.addHandler(fh)

create_logger() ¤

Create a logger for the program with default settings.

Source code in autocorpus/__init__.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
def create_logger():
    """Create a logger for the program with default settings."""
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.INFO)

    # create console handler
    ch = logging.StreamHandler()
    ch.setFormatter(_log_formatter)

    # add the handlers to the logger
    logger.addHandler(ch)

    return logger