fruafr.log.lib package

Submodules

fruafr.log.lib.common module

Contains common utils for the CLI

fruafr.log.lib.formatter module

Uses standards python logging logger objects to template the formatter string and create the formatter

Reference: https://docs.python.org/3/library/logging.html#logger-objects

Contains: - FormatterClass

class fruafr.log.lib.formatter.FormatterClass(fmt=None, datefmt=None, style='%', validate=True)[source]

Bases: Formatter

basic(style: str = '%') str[source]

Set the format string to basic format as a string Creates the formatter accordingly :param style: The style string. :type style: str, optional :param Can be %: ‘%’] :param { or ( [default: ‘%’]

Returns:

The basic format string

create_format_str(kwargs: list, sep: str = ' ', style: str = '%') None[source]

Creates the format string from kwargs. Resets it if pre-existing :param kwargs: list of kwargs :type kwargs: list :param sep: separator. [defaults: space] :type sep: str, optional :param style: The style string. :type style: str, optional :param Can be %: ‘%’] :param { or ( [default: ‘%’]

custom(fmtstr: str, style: str = '%') str[source]

Set the format string to a custom string Creates the formatter accordingly :param style: The style string. :type style: str, optional :param Can be %: ‘%’] :param { or ( [default: ‘%’]

Returns:

The custom format string

default(style: str = '%') str[source]

Set the format string to default format as a String Creates the formatter accordingly :param style: The style string. :type style: str, optional :param Can be %: ‘%’] :param { or ( [default: ‘%’]

Returns:

The default format string

property fmt: str

Returns a format string :returns: The format string

raw(style: str = '%') str[source]

Set the format string to raw format as a string Creates the formatter accordingly :param style: The style string. :type style: str, optional :param Can be %: ‘%’] :param { or ( [default: ‘%’]

Returns:

The raw format string

simple(style: str = '%') str[source]

Set the format string to simple format as a string Creates the formatter accordingly :param style: The style string. :type style: str, optional :param Can be %: ‘%’] :param { or ( [default: ‘%’]

Returns:

The simple format string

property supported: list

Returns the supported format attribuates :returns: The supported format attribuates as a list

typical(style: str = '%') str[source]

Set the format string to typical format as a string Creates the formatter accordingly :param style: The style string. :type style: str, optional :param Can be %: ‘%’] :param { or ( [default: ‘%’]

Returns:

The typical format string

fruafr.log.lib.logger module

Extends logging.Logger Uses standards python logging.

Reference: https://docs.python.org/3/library/logging.html Contains: - LoggerClass

class fruafr.log.lib.logger.LoggerClass(name, level=0)[source]

Bases: Logger

LoggerClass extends logging.Logger

property default_formatter: Formatter

Returns the logger default formatter :returns: The logger formatter

get_handler(name: str) Handler[source]

Return an Handler based on its name :param name: name of the Handler :type name: str

remove_handler(name: str) None[source]

Remove an Handler identified by its name :param name: name of the Handler :type name: str

set_handler_formatter(name: str, newformatter: Formatter) None[source]

Change the Handler Formatter. The handler is identified by its name :param name: name of the Handler :type name: str :param newformatter: the new handler formatter :type newformatter: logging.Formatter

set_handler_level(name: str, newlevel: int = 0) None[source]

Set the Handler level. The handler is identified by its name :param name: name of the Handler :type name: str :param newlevel: one of the logging levels. :type newlevel: int :param Defaults to logging.NOTSET:

set_handler_name(oldname: str, newname: str) None[source]

Change the Handler name. The handler is identified by its old name :param oldname: current name of the Handler :type oldname: str :param newname: new name of the Handler to change the current name to :type newname: str

fruafr.log.lib.templating module

Templating utilities for custom logging message

class fruafr.log.lib.templating.Templating[source]

Bases: object

Class to perform basic templating

classmethod apply_template(template: str, valuesdict: dict) str[source]

Render the template :param template: str: template string :param valuesdict: dict: values of the template variables

Returns:

The templated string

classmethod create_template(variables: list, separator: str = ',') str[source]

Prepare a template from the variables provided :param variables: List of variables :type variables: list :param separator: Separator [default: ‘,’] :type separator: str

Returns:

The template string (in string.Template format)

classmethod validate_template(template: str, variables: []) str[source]

Validate that each variable in the variables list is found in the template :param template: template string :type template: str :param variables: list of variables :type variables: list

Returns:

The first variable not found in the template (otherwise returns None)

Module contents