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
- 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
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:
LoggerLoggerClass 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
fruafr.log.lib.templating module¶
Templating utilities for custom logging message
- class fruafr.log.lib.templating.Templating[source]¶
Bases:
objectClass 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)