Skip to content

Logger

logger_error(module, message)

Record an error in the log.

Parameters:

Name Type Description Default
module str

Name of module that function is being called from. It should always be "name".

required
message str

Error message.

required
Source code in src/mtg_pynance/logger.py
def logger_error(module: str, message: str):
    """
    Record an error in the log.

    Parameters
    ----------
    module: str
        Name of module that function is being called from.
        It should always be "__name__".
    message: str
        Error message.
    """
    logger = logging.getLogger(module)
    logger.error(message)

make_logger(workspace_path)

Make mtg_pynance logger.

Parameters:

Name Type Description Default
workspace_path Path

The project workspace path

required
Source code in src/mtg_pynance/logger.py
def make_logger(workspace_path: Path):
    """
    Make mtg_pynance logger.

    Parameters
    ----------
    workspace_path: pathlib.Path
        The project workspace path
    """
    logger = logging.getLogger(ROOT_LOGGER)
    fmt = logging.Formatter("%(name)s - %(levelname)s - %(message)s")
    fh = logging.FileHandler(workspace_path / "log.txt", mode="w")
    fh.setFormatter(fmt)
    fh.setLevel(logging.INFO)
    logger.setLevel(logging.INFO)
    logger.addHandler(fh)