:py:mod:`eelib.utils.logging_helpers` ===================================== .. py:module:: eelib.utils.logging_helpers .. autoapi-nested-parse:: Logging helper with custom format and functions to set logger. | Author: elenia@TUBS | Copyright 2024 elenia | This file is part of eELib, which is free software under the terms of the GNU GPL Version 3. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: eelib.utils.logging_helpers.CustomFormatter Functions ~~~~~~~~~ .. autoapisummary:: eelib.utils.logging_helpers.clear_logger eelib.utils.logging_helpers.set_console_logger eelib.utils.logging_helpers.set_file_logger Attributes ~~~~~~~~~~ .. autoapisummary:: eelib.utils.logging_helpers.LOGGING_FORMAT .. py:data:: LOGGING_FORMAT :value: "'%(asctime)s | %(levelname)-9s| %(threadName)s | %(name)s:%(lineno)d - %(message)s'" .. py:class:: CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None) Bases: :py:obj:`logging.Formatter` CustomFormatter with different colors for logging levels. Specialization of logging.Formatter. .. py:attribute:: grey :value: "'\\x1b[38;20m'" .. py:attribute:: yellow :value: "'\\x1b[33;20m'" .. py:attribute:: red :value: "'\\x1b[31;20m'" .. py:attribute:: bold_red :value: "'\\x1b[31;1m'" .. py:attribute:: reset :value: "'\\x1b[0m'" .. py:attribute:: format_str :value: "'%(asctime)s | %(levelname)-9s| %(threadName)s | %(name)s:%(lineno)d - %(message)s'" .. py:attribute:: FORMATS .. py:method:: format(record: object) -> str Overrides format method. :param record: record to log. :type record: object :returns: Formatted log string. :rtype: str .. py:function:: clear_logger() Function to remove existing loggers. .. py:function:: set_console_logger(level: int = logging.DEBUG) Set console output logger. All messages will be printed to StdOut. :param level: Logging level. Defaults to logging.DEBUG. :type level: int .. py:function:: set_file_logger(level: int = logging.DEBUG, filename: str = 'eELib.log') Set file logger. All messages will be written to the file with given filename. :param level: Logging level. Defaults to logging.DEBUG. :type level: int :param filename: Logfile filename. Defaults to "eELib.log". :type filename: str