ngs_tools.logging

Module Contents

Classes

Logger

Custom logger that provides namespacing functionality.

Functions

silence_logger(name)

Given a logger name, silence it completely.

set_logger(log)

Set the logger to the provided Logger instance. Use this function

Attributes

logger

ngs_tools.logging.silence_logger(name: str)

Given a logger name, silence it completely.

Parameters:

name – Logger name to silence

class ngs_tools.logging.Logger(name: Optional[str] = None)

Custom logger that provides namespacing functionality.

The following loggers are silenced by default:

anndata, h5py, numba, pysam, pystan

FORMAT

Static attribute that encodes the logging format string

logger

The logger object

ch

A logging.Streamhandler object that sets the format

FORMAT = '[%(asctime)s] %(levelname)7s %(message)s'
namespaced(namespace: str)

Function decorator to set the logging namespace for the duration of the function.

Parameters:

namespace – The namespace

namespaced_context(namespace: str)

Context manager to set the logging namespace.

Parameters:

namespace – The namespace

namespace_message(message: str) str

Add namespace information at the beginning of the logging message.

Parameters:

message – The logging message

Returns:

The namespaced message

addHandler(hdlr: logging.Handler, format: bool = True)
removeHandler(*args, **kwargs)
setLevel(*args, **kwargs)
debug(message, *args, **kwargs)
info(message, *args, **kwargs)
warning(message, *args, **kwargs)
exception(message, *args, **kwargs)
critical(message, *args, **kwargs)
error(message, *args, **kwargs)
ngs_tools.logging.logger
ngs_tools.logging.set_logger(log: Logger)

Set the logger to the provided Logger instance. Use this function to override the default logger for this (ngs-tools) library from libraries that use this library (ngs-tools) as a dependency.

Parameters:

log – The logger