vcorelib.logging package#

Submodules#

vcorelib.logging.args module#

A module implementing command-line option handling for logger initialization.

vcorelib.logging.args.forward_flags(args: Namespace, names: Iterable[str]) Iterator[str][source]#

Forward flag arguments.

vcorelib.logging.args.forward_logging_flags(args: Namespace) Iterator[str][source]#

Forward logging-related flags passed to this program to some other program.

vcorelib.logging.args.init_logging(args: Namespace, default_format: str = '%(name)-36s - %(levelname)-6s - %(message)s') None[source]#

Initialize logging based on command-line arguments.

vcorelib.logging.args.logging_args(parser: ArgumentParser, curses: bool = True, uvloop: bool = True) None[source]#

Add logging related command-line arguments to a parser.

vcorelib.logging.list module#

A module implementing a logger interface that uses lists.

class vcorelib.logging.list.ListLogger(level=0)[source]#

Bases: Handler

An interface facilitating sending log messages to browser tabs.

static create(fmt: str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s') ListLogger[source]#

Create an instance of this handler.

drain() list[LogRecord][source]#

Drain messages.

drain_str() list[str][source]#

Drain formatted messages.

drain_str_iter() Iterator[str][source]#

Iterate over string messages.

dropped: int#
emit(record: LogRecord) None[source]#

Send the log message.

log_messages: list[LogRecord]#
max_size: int = 1024#

vcorelib.logging.time module#

A module with interfaces for time and logging integration.

vcorelib.logging.time.log_time(log: Logger | LoggerAdapter[Any], message: str, *args, level: int = 20, reminder: bool = False, **kwargs) Iterator[None][source]#

A simple context manager for conveniently logging time taken for a task.

Module contents#

Utilities for logging information.

class vcorelib.logging.ListLogger(level=0)[source]#

Bases: Handler

An interface facilitating sending log messages to browser tabs.

static create(fmt: str = '%(asctime)s - %(name)s - %(levelname)s - %(message)s') ListLogger[source]#

Create an instance of this handler.

drain() list[LogRecord][source]#

Drain messages.

drain_str() list[str][source]#

Drain formatted messages.

drain_str_iter() Iterator[str][source]#

Iterate over string messages.

dropped: int#
emit(record: LogRecord) None[source]#

Send the log message.

log_messages: list[LogRecord]#
max_size: int = 1024#
class vcorelib.logging.LoggerMixin(logger: Logger | LoggerAdapter[Any] = None, logger_name: str = None)[source]#

Bases: object

A class that provides an inheriting class a logger attribute.

governed_log(limiter: RateLimiter, message: str, *args, level: int = 20, time_ns: int = None, **kwargs) None[source]#

Log a message but limit the rate.

log_time(message: str, *args, level: int = 20, reminder: bool = False, **kwargs) Iterator[None][source]#

A simple wrapper.

logger: Logger | LoggerAdapter[Any]#
vcorelib.logging.forward_flags(args: Namespace, names: Iterable[str]) Iterator[str][source]#

Forward flag arguments.

vcorelib.logging.forward_logging_flags(args: Namespace) Iterator[str][source]#

Forward logging-related flags passed to this program to some other program.

vcorelib.logging.init_logging(args: Namespace, default_format: str = '%(name)-36s - %(levelname)-6s - %(message)s') None[source]#

Initialize logging based on command-line arguments.

vcorelib.logging.log_time(log: Logger | LoggerAdapter[Any], message: str, *args, level: int = 20, reminder: bool = False, **kwargs) Iterator[None][source]#

A simple context manager for conveniently logging time taken for a task.

vcorelib.logging.logging_args(parser: ArgumentParser, curses: bool = True, uvloop: bool = True) None[source]#

Add logging related command-line arguments to a parser.

vcorelib.logging.normalize(logger: Logger | LoggerAdapter[Any]) Logger[source]#

Normalize a logger instance.