annalist package

Submodules

annalist.annalist module

Main module.

class annalist.annalist.Annalist(*args, **kw)[source]

Bases: object

Annalist Class.

Attributes

loggerAnnalistLogger

A custom subclass of logging.Logger which allows additional user-defined variables to be parsed from the formatter and added dynamically.

stream_handlerlogging.StreamHandler

Logging handler that sends output to streams such as sys.stdout, sys.stderr, etc. Will be passed the stream_formatter attribute. See documentation for logging.StreamHandler for more info.

file_handlerlogging.FileHandler

Logging handler that sends output to the logfile defined by the logfile attribute. Will be passed the file_formatter attribute. See `logging.FileHandler documentation`_ for more info.

stream_formatterstr

Stream formatting string to be parsed by logging.Formatter. Used to set up stream_handler. See `logging.Formatter documentation`_ for more info.

file_formatterstr

File formatting string to be parsed by logging.Formatter. See `logging.Formatter documentation`_ for more info.

property analyst_name

The analyst_name property.

configure(logfile: str | PathLike[str] | None = None, analyst_name: str | None = None, file_format_str: str | None = None, stream_format_str: str | None = None, level_filter: str = 'INFO', default_level: str = 'INFO')[source]

Configure the Annalist.

property default_level

The default_level property.

property level_filter

The level_filter property.

log_call(message, level, func, ret_val, extra_data, *args, **kwargs)[source]

Log function call.

static parse_formatter(format_string)[source]

Parse a formatting string.

Extracts field names from a formatting string. Only printf-style (%-style) strings are supported.

Parameters

format_stringstr

A printf-style (%-style) string.

Returns

list

A list of parameter names in the order that they appear in the format string.

set_file_formatter(formatter, logfile: str | PathLike[str] | None = None)[source]

Change the file formatter of the logger.

set_stream_formatter(formatter)[source]

Change the stream formatter of the logger.

class annalist.annalist.AnnalistLogger(name, extra_attributes)[source]

Bases: Logger

Custom Logger class to add contextual information.

add_attributes(extra_attributes: list)[source]

Add user-defined fields as attributes.

makeRecord(*args, **kwargs)[source]

Override Logger.makeRecord to accept user-defined fields.

class annalist.annalist.Singleton(name, bases, mmbs)[source]

Bases: type

Singleton Metaclass.

Ensures that only one instance of the inheriting class is created.

annalist.annalist.clean_str(s)[source]

Clean a string for nice clean logging.

Module contents

Top-level package for Annalist.