jgdv.logging.config

Classes

JGDVLogConfig

Utility class to setup [stdout, stderr, file] logging.

PrintCapture_m

Mixin for redirecting builtins.print to a file

Module Contents

class jgdv.logging.config.JGDVLogConfig[source]

Utility class to setup [stdout, stderr, file] logging.

Also creates a ‘printer’ logger, so instead of using print, tasks can notify the user using the printer, which also includes the notifications into the general log trace

The Printer has a number of children, which can be controlled to customise verbosity.

Standard _printer children::

action_exec, action_group, artifact, cmd, fail, header, help, queue, report, skip, sleep, success, task, task_header, task_loop, task_state, track

_install_logger_override() <Unknown>[source]
Return type:

None

_install_record_override() <Unknown>[source]

Sets a custom LogRecord subclass as the factory

Return type:

None

_register_new_names() <Unknown>[source]
Return type:

None

_setup_logging_extra(config) <Unknown>[source]

read the doot config logging section setting up each entry other than stream, file, printer, and subprinters

Parameters:

config (jgdv.structs.chainguard.ChainGuard)

Return type:

None

activate_spec(
spec,
*,
override=False,
) <Unknown>[source]

Add a spec to the registry and activate it

Parameters:
Return type:

None

report() <Unknown>[source]

Utility method to inspect the state of logging.

Return type:

None

reset() <Unknown>[source]

Reset the config to the initial specs

Return type:

None

set_level(level) <Unknown>[source]

Set the active logging level

Parameters:

level (int | str)

Return type:

None

setup(config, *, force=False) <Unknown>[source]

a setup that uses config values

Parameters:
  • config (dict | jgdv.structs.chainguard.ChainGuard)

  • force (bool)

Return type:

None

subprinter(*names, prefix=None) <Unknown>[source]

Get a subprinter of the printer logger. The First name needs to be a registered subprinter. Additional names are unconstrained

Parameters:
  • names (str)

  • prefix (jgdv.Maybe[str])

Return type:

jgdv.logging._interface.Logger

_initial_spec: jgdv.logging.logger_spec.LoggerSpec
_printer_initial_spec: jgdv.logging.logger_spec.LoggerSpec
_registry: dict[str, jgdv.logging.logger_spec.LoggerSpec]
is_setup: bool
levels: ClassVar[type[jgdv.logging._interface.LogLevel_e]]
logger_cls: ClassVar[type[jgdv.logging._interface.Logger]]
record_cls: ClassVar[type[logging.LogRecord]]
root: jgdv.logging._interface.Logger
class jgdv.logging.config.PrintCapture_m[source]

Mixin for redirecting builtins.print to a file

capture_printing_to_file(
path=API.default_print_file,
*,
disable_warning=False,
) <Unknown>[source]

Modifies builtins.print to also print to a file

Setup a file handler for a separate logger, to keep a trace of anything printed. Strips colour print command codes out of any string printed strings are logged at DEBUG level

Parameters:
Return type:

None

remove_print_capture() <Unknown>[source]

removes a previously advised builtins.print

Return type:

None

original_print: jgdv.Maybe[collections.abc.Callable]