Log switch to bitwise flag settings for console format type

Has the following settings
TIME, TIME_SECONDS, TIME_MILLISECONDS, TIME_MICROSECONDS: enable time output in different formats
TIME and TIME_MILLISECONDS are equivalent, if multiple are set the smallest precision wins
TIMEZONE: add time zone to time output
NAME: log group name
FILE: short file name
FUNCTION: function name
LINENO: line number

There is a class with quick grouped settings
ConsoleFormatSettings
ALL: all options enabled, time is in milliseconds
CONDENSED: time without time zone, file and line number
MINIMAL: only time without time zone
BARE: only the message, no other info
This commit is contained in:
Clemens Schwaighofer
2025-11-19 11:25:49 +09:00
parent 2e0b1f5951
commit 1280b2f855
10 changed files with 183 additions and 248 deletions

View File

@@ -11,6 +11,7 @@ from datetime import datetime
import time
from pathlib import Path
import atexit
from enum import Flag, auto
from typing import MutableMapping, TextIO, TypedDict, Any, TYPE_CHECKING, cast
from corelibs.logging_handling.logging_level_handling.logging_level import LoggingLevel
from corelibs.string_handling.text_colors import Colors
@@ -20,6 +21,38 @@ if TYPE_CHECKING:
from multiprocessing import Queue
class ConsoleFormat(Flag):
"""console format type bitmap flags"""
TIME = auto()
TIME_SECONDS = auto()
TIME_MILLISECONDS = auto()
TIME_MICROSECONDS = auto()
TIMEZONE = auto()
NAME = auto()
FILE = auto()
FUNCTION = auto()
LINENO = auto()
class ConsoleFormatSettings:
"""Console format quick settings groups"""
# shows everything, time with milliseconds, and time zone, log name, file, function, line number
ALL = (
ConsoleFormat.TIME |
ConsoleFormat.TIMEZONE |
ConsoleFormat.NAME |
ConsoleFormat.FILE |
ConsoleFormat.FUNCTION |
ConsoleFormat.LINENO
)
# show time with no time zone, file and line
CONDENSED = ConsoleFormat.TIME | ConsoleFormat.FILE | ConsoleFormat.LINENO
# only time
MINIMAL = ConsoleFormat.TIME
# only message
BARE = ConsoleFormat(0)
# MARK: Log settings TypedDict
class LogSettings(TypedDict):
"""log settings, for Log setup"""
@@ -28,8 +61,7 @@ class LogSettings(TypedDict):
per_run_log: bool
console_enabled: bool
console_color_output_enabled: bool
console_format_type: str
console_iso_precision: str
console_format_type: ConsoleFormat
add_start_info: bool
add_end_info: bool
log_queue: 'Queue[str] | None'
@@ -41,18 +73,6 @@ class LoggerInit(TypedDict):
log_queue: 'Queue[str] | None'
# show log title, file, function and line number types
CONSOLE_FORMAT_TYPE_NORMAL = 'normal'
# show file and line number only
CONSOLE_FORMAT_TYPE_CONDENSED = 'condensed'
# only show timestamp, log level and message
CONSOLE_FORMAT_TYPE_MINIMAL = 'minimal'
# for console ISO time format
CONSOLE_ISO_TIME_SECONDS = 'seconds'
CONSOLE_ISO_TIME_MILLISECONDS = 'milliseconds'
CONSOLE_ISO_TIME_MICROSECONDS = 'microseconds'
# MARK: Custom color filter
class CustomConsoleFormatter(logging.Formatter):
"""
@@ -70,21 +90,6 @@ class CustomConsoleFormatter(logging.Formatter):
LoggingLevel.EXCEPTION.name: Colors.magenta_bright, # will never be written to console
}
# def formatTime(self, record: logging.LogRecord, datefmt: str | None = None):
# """
# Set timestamp in ISO8601 format
# Arguments:
# record {logging.LogRecord} -- _description_
# Keyword Arguments:
# datefmt {str | None} -- _description_ (default: {None})
# Returns:
# _type_ -- _description_
# """
# return datetime.fromtimestamp(record.created).astimezone().isoformat(sep=' ', timespec='milliseconds')
def format(self, record: logging.LogRecord) -> str:
"""
set the color highlight
@@ -439,8 +444,7 @@ class Log(LogParent):
"console_enabled": True,
"console_color_output_enabled": True,
# do not print log title, file, function and line number
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": True,
"add_end_info": False,
"log_queue": None,
@@ -451,7 +455,10 @@ class Log(LogParent):
self,
log_path: Path,
log_name: str,
log_settings: dict[str, 'LoggingLevel | str | bool | None | Queue[str]'] | LogSettings | None = None,
log_settings: (
dict[str, 'LoggingLevel | str | bool | None | Queue[str] | ConsoleFormat'] | # noqa: E501 # pylint: disable=line-too-long
LogSettings | None
) = None,
other_handlers: dict[str, Any] | None = None
):
LogParent.__init__(self)
@@ -496,7 +503,6 @@ class Log(LogParent):
'stream_handler',
self.log_settings['log_level_console'],
console_format_type=self.log_settings['console_format_type'],
console_iso_precision=self.log_settings['console_iso_precision']
))
# add other handlers,
if other_handlers is not None:
@@ -523,7 +529,8 @@ class Log(LogParent):
# MARK: parse log settings
def __parse_log_settings(
self,
log_settings: dict[str, 'LoggingLevel | str | bool | None | Queue[str]'] | LogSettings | None
log_settings: dict[str, 'LoggingLevel | str | bool | None | Queue[str] | ConsoleFormat'] | # noqa: E501 # pylint: disable=line-too-long
LogSettings | None
) -> LogSettings:
# skip with defaul it not set
if log_settings is None:
@@ -554,26 +561,9 @@ class Log(LogParent):
__setting = self.DEFAULT_LOG_SETTINGS.get(__log_entry, True)
default_log_settings[__log_entry] = __setting
# check console log type
default_log_settings['console_format_type'] = cast('str', log_settings.get(
default_log_settings['console_format_type'] = cast('ConsoleFormat', log_settings.get(
'console_format_type', self.DEFAULT_LOG_SETTINGS['console_format_type']
))
# if not valid
if default_log_settings['console_format_type'] not in [
CONSOLE_FORMAT_TYPE_NORMAL,
CONSOLE_FORMAT_TYPE_CONDENSED,
CONSOLE_FORMAT_TYPE_MINIMAL,
]:
default_log_settings['console_format_type'] = self.DEFAULT_LOG_SETTINGS['console_format_type']
# check console iso time precision
default_log_settings['console_iso_precision'] = cast('str', log_settings.get(
'console_iso_precision', self.DEFAULT_LOG_SETTINGS['console_iso_precision']
))
if default_log_settings['console_iso_precision'] not in [
CONSOLE_ISO_TIME_SECONDS,
CONSOLE_ISO_TIME_MILLISECONDS,
CONSOLE_ISO_TIME_MICROSECONDS,
]:
default_log_settings['console_iso_precision'] = self.DEFAULT_LOG_SETTINGS['console_iso_precision']
# check log queue
__setting = log_settings.get('log_queue', self.DEFAULT_LOG_SETTINGS['log_queue'])
if __setting is not None:
@@ -612,51 +602,89 @@ class Log(LogParent):
self, handler_name: str,
log_level_console: LoggingLevel = LoggingLevel.WARNING,
filter_exceptions: bool = True,
console_format_type: str = CONSOLE_FORMAT_TYPE_NORMAL,
console_iso_precision: str = CONSOLE_ISO_TIME_MILLISECONDS
console_format_type: ConsoleFormat = ConsoleFormatSettings.ALL,
) -> logging.StreamHandler[TextIO]:
# console logger
if not self.validate_log_level(log_level_console):
log_level_console = self.DEFAULT_LOG_LEVEL_CONSOLE
console_handler = logging.StreamHandler()
# format layouts
format_string = (
# '[%(asctime)s.%(msecs)03d] '
'[%(asctime)s] '
'[%(name)s] '
'[%(filename)s:%(funcName)s:%(lineno)d] '
'<%(levelname)s> '
'%(message)s'
)
if console_format_type == CONSOLE_FORMAT_TYPE_CONDENSED:
format_string = (
'[%(asctime)s] '
'[%(filename)s:%(lineno)d] '
'<%(levelname)s> '
'%(message)s'
)
elif console_format_type == CONSOLE_FORMAT_TYPE_MINIMAL:
format_string = (
'[%(asctime)s] '
'<%(levelname)s> '
'%(message)s'
)
format_date = "%Y-%m-%d %H:%M:%S"
print(f"Console format type: {console_format_type}")
# build the format string based on what flags are set
format_string = ''
# time part if any of the times are requested
if (
ConsoleFormat.TIME in console_format_type or
ConsoleFormat.TIME_SECONDS in console_format_type or
ConsoleFormat.TIME_MILLISECONDS in console_format_type or
ConsoleFormat.TIME_MICROSECONDS in console_format_type
):
format_string += '[%(asctime)s] '
# set log name
if ConsoleFormat.NAME in console_format_type:
format_string += '[%(name)s] '
# for any file/function/line number call
if (
ConsoleFormat.FILE in console_format_type or
ConsoleFormat.FUNCTION in console_format_type or
ConsoleFormat.LINENO in console_format_type
):
format_string += '['
set_group: list[str] = []
if ConsoleFormat.FILE in console_format_type:
set_group.append('%(filename)s')
if ConsoleFormat.FUNCTION in console_format_type:
set_group.append('%(funcName)s')
if ConsoleFormat.LINENO in console_format_type:
set_group.append('%(lineno)d')
format_string += ':'.join(set_group)
format_string += '] '
# always level + message
format_string += '<%(levelname)s> %(message)s'
# basic date, but this will be overridden to ISO in formatTime
# format_date = "%Y-%m-%d %H:%M:%S"
# color or not
if self.log_settings['console_color_output_enabled']:
formatter_console = CustomConsoleFormatter(format_string, datefmt=format_date)
# formatter_console = CustomConsoleFormatter(format_string, datefmt=format_date)
formatter_console = CustomConsoleFormatter(format_string)
else:
formatter_console = logging.Formatter(format_string, datefmt=format_date)
print(f"PREC: {console_iso_precision}")
# this one needs lambda self, ...
# logging.Formatter.formatTime = (
formatter_console.formatTime = (
lambda record, datefmt=None:
datetime
.fromtimestamp(record.created)
.astimezone()
.isoformat(sep="T", timespec=console_iso_precision)
)
# formatter_console = logging.Formatter(format_string, datefmt=format_date)
formatter_console = logging.Formatter(format_string)
# default for TIME is milliseconds
# if we have multiple set, the smallest precision wins
if ConsoleFormat.TIME_MICROSECONDS in console_format_type:
iso_precision = 'microseconds'
elif (
ConsoleFormat.TIME_MILLISECONDS in console_format_type or
ConsoleFormat.TIME in console_format_type
):
iso_precision = 'milliseconds'
elif ConsoleFormat.TIME_SECONDS in console_format_type:
iso_precision = 'seconds'
else:
iso_precision = 'milliseconds'
# do timestamp modification only if we have time requested
if (
ConsoleFormat.TIME in console_format_type or
ConsoleFormat.TIME_SECONDS in console_format_type or
ConsoleFormat.TIME_MILLISECONDS in console_format_type or
ConsoleFormat.TIME_MICROSECONDS in console_format_type
):
# if we have with TZ we as the asttimezone call
if ConsoleFormat.TIMEZONE in console_format_type:
formatter_console.formatTime = (
lambda record, datefmt=None:
datetime
.fromtimestamp(record.created)
.astimezone()
.isoformat(sep=" ", timespec=iso_precision)
)
else:
formatter_console.formatTime = (
lambda record, datefmt=None:
datetime
.fromtimestamp(record.created)
.isoformat(sep=" ", timespec=iso_precision)
)
console_handler.set_name(handler_name)
console_handler.setLevel(log_level_console.name)
# do not show exceptions logs on console

View File

@@ -6,7 +6,7 @@ Log logging_handling.log testing
import sys
from pathlib import Path
# this is for testing only
from corelibs.logging_handling.log import Log, Logger, CONSOLE_FORMAT_TYPE_MINIMAL, CONSOLE_ISO_TIME_MICROSECONDS
from corelibs.logging_handling.log import Log, Logger, ConsoleFormat, ConsoleFormatSettings
from corelibs.debug_handling.debug_helpers import exception_stack, call_stack
from corelibs.logging_handling.logging_level_handling.logging_level import LoggingLevel
@@ -25,13 +25,19 @@ def main():
"log_level_file": 'DEBUG',
# "console_color_output_enabled": False,
"per_run_log": True,
# Set console log type
"console_format_type": CONSOLE_FORMAT_TYPE_MINIMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MICROSECONDS,
# Set console log type, must be sent as value for ConsoleFormat or bitwise of ConsoleFormatType
# "console_format_type": ConsoleFormatSettings.BARE,
# "console_format_type": ConsoleFormatSettings.MINIMAL,
# "console_format_type": ConsoleFormatType.TIME_MICROSECONDS | ConsoleFormatType.NAME,
# "console_format_type": ConsoleFormatType.NAME,
"console_format_type": ConsoleFormat.TIME | ConsoleFormat.TIMEZONE | ConsoleFormat.LINENO,
}
)
logn = Logger(log.get_logger_settings())
log.info("ConsoleFormatType FILE is: %s", ConsoleFormat.FILE)
log.info("ConsoleFormatSettings ALL is: %s", ConsoleFormatSettings.ALL)
log.logger.debug('[NORMAL] Debug test: %s', log.logger.name)
log.lg.debug('[NORMAL] Debug test: %s', log.logger.name)
log.debug('[NORMAL-] Debug test: %s', log.logger.name)

View File

@@ -11,12 +11,7 @@ from corelibs.logging_handling.log import (
Log,
LogParent,
LogSettings,
CONSOLE_FORMAT_TYPE_NORMAL,
CONSOLE_FORMAT_TYPE_CONDENSED,
CONSOLE_FORMAT_TYPE_MINIMAL,
CONSOLE_ISO_TIME_MILLISECONDS,
CONSOLE_ISO_TIME_SECONDS,
CONSOLE_ISO_TIME_MICROSECONDS,
ConsoleFormatSettings,
)
from corelibs.logging_handling.logging_level_handling.logging_level import LoggingLevel
@@ -39,8 +34,7 @@ def basic_log_settings() -> LogSettings:
"per_run_log": False,
"console_enabled": True,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,
@@ -107,10 +101,10 @@ class TestLogSettingsParsing:
assert log.log_settings["console_enabled"] == Log.DEFAULT_LOG_SETTINGS["console_enabled"]
assert log.log_settings["per_run_log"] == Log.DEFAULT_LOG_SETTINGS["per_run_log"]
def test_parse_console_format_type_normal(self, tmp_log_path: Path):
"""Test parsing with console_format_type set to normal"""
def test_parse_console_format_type_all(self, tmp_log_path: Path):
"""Test parsing with console_format_type set to ALL"""
settings: dict[str, Any] = {
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_format_type": ConsoleFormatSettings.ALL,
}
log = Log(
log_path=tmp_log_path,
@@ -118,12 +112,12 @@ class TestLogSettingsParsing:
log_settings=settings # type: ignore
)
assert log.log_settings["console_format_type"] == CONSOLE_FORMAT_TYPE_NORMAL
assert log.log_settings["console_format_type"] == ConsoleFormatSettings.ALL
def test_parse_console_format_type_condensed(self, tmp_log_path: Path):
"""Test parsing with console_format_type set to condensed"""
"""Test parsing with console_format_type set to CONDENSED"""
settings: dict[str, Any] = {
"console_format_type": CONSOLE_FORMAT_TYPE_CONDENSED,
"console_format_type": ConsoleFormatSettings.CONDENSED,
}
log = Log(
log_path=tmp_log_path,
@@ -131,12 +125,12 @@ class TestLogSettingsParsing:
log_settings=settings # type: ignore
)
assert log.log_settings["console_format_type"] == CONSOLE_FORMAT_TYPE_CONDENSED
assert log.log_settings["console_format_type"] == ConsoleFormatSettings.CONDENSED
def test_parse_console_format_type_minimal(self, tmp_log_path: Path):
"""Test parsing with console_format_type set to minimal"""
"""Test parsing with console_format_type set to MINIMAL"""
settings: dict[str, Any] = {
"console_format_type": CONSOLE_FORMAT_TYPE_MINIMAL,
"console_format_type": ConsoleFormatSettings.MINIMAL,
}
log = Log(
log_path=tmp_log_path,
@@ -144,105 +138,34 @@ class TestLogSettingsParsing:
log_settings=settings # type: ignore
)
assert log.log_settings["console_format_type"] == CONSOLE_FORMAT_TYPE_MINIMAL
assert log.log_settings["console_format_type"] == ConsoleFormatSettings.MINIMAL
def test_parse_console_format_type_bare(self, tmp_log_path: Path):
"""Test parsing with console_format_type set to BARE"""
settings: dict[str, Any] = {
"console_format_type": ConsoleFormatSettings.BARE,
}
log = Log(
log_path=tmp_log_path,
log_name="test",
log_settings=settings # type: ignore
)
assert log.log_settings["console_format_type"] == ConsoleFormatSettings.BARE
def test_parse_console_format_type_invalid(self, tmp_log_path: Path):
"""Test parsing with invalid console_format_type falls back to default"""
"""Test parsing with invalid console_format_type raises TypeError"""
settings: dict[str, Any] = {
"console_format_type": "invalid_format",
}
log = Log(
log_path=tmp_log_path,
log_name="test",
log_settings=settings # type: ignore
)
# Should fall back to default
assert log.log_settings["console_format_type"] == Log.DEFAULT_LOG_SETTINGS["console_format_type"]
def test_parse_console_iso_precision_seconds(self, tmp_log_path: Path):
"""Test parsing with console_iso_precision set to seconds"""
settings: dict[str, Any] = {
"console_iso_precision": CONSOLE_ISO_TIME_SECONDS,
}
log = Log(
log_path=tmp_log_path,
log_name="test",
log_settings=settings # type: ignore
)
assert log.log_settings["console_iso_precision"] == CONSOLE_ISO_TIME_SECONDS
def test_parse_console_iso_precision_milliseconds(self, tmp_log_path: Path):
"""Test parsing with console_iso_precision set to milliseconds"""
settings: dict[str, Any] = {
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
}
log = Log(
log_path=tmp_log_path,
log_name="test",
log_settings=settings # type: ignore
)
assert log.log_settings["console_iso_precision"] == CONSOLE_ISO_TIME_MILLISECONDS
def test_parse_console_iso_precision_microseconds(self, tmp_log_path: Path):
"""Test parsing with console_iso_precision set to microseconds"""
settings: dict[str, Any] = {
"console_iso_precision": CONSOLE_ISO_TIME_MICROSECONDS,
}
log = Log(
log_path=tmp_log_path,
log_name="test",
log_settings=settings # type: ignore
)
assert log.log_settings["console_iso_precision"] == CONSOLE_ISO_TIME_MICROSECONDS
def test_parse_console_iso_precision_invalid(self, tmp_log_path: Path):
"""Test parsing with invalid console_iso_precision falls back to default"""
settings: dict[str, Any] = {
"console_iso_precision": "invalid_precision",
}
log = Log(
log_path=tmp_log_path,
log_name="test",
log_settings=settings # type: ignore
)
# Should fall back to default
assert log.log_settings["console_iso_precision"] == Log.DEFAULT_LOG_SETTINGS["console_iso_precision"]
def test_parse_both_console_settings_valid(self, tmp_log_path: Path):
"""Test parsing with both console_format_type and console_iso_precision set"""
settings: dict[str, Any] = {
"console_format_type": CONSOLE_FORMAT_TYPE_CONDENSED,
"console_iso_precision": CONSOLE_ISO_TIME_MICROSECONDS,
}
log = Log(
log_path=tmp_log_path,
log_name="test",
log_settings=settings # type: ignore
)
assert log.log_settings["console_format_type"] == CONSOLE_FORMAT_TYPE_CONDENSED
assert log.log_settings["console_iso_precision"] == CONSOLE_ISO_TIME_MICROSECONDS
def test_parse_both_console_settings_invalid(self, tmp_log_path: Path):
"""Test parsing with both console settings invalid falls back to defaults"""
settings: dict[str, Any] = {
"console_format_type": "invalid_format",
"console_iso_precision": "invalid_precision",
}
log = Log(
log_path=tmp_log_path,
log_name="test",
log_settings=settings # type: ignore
)
# Should fall back to defaults
assert log.log_settings["console_format_type"] == Log.DEFAULT_LOG_SETTINGS["console_format_type"]
assert log.log_settings["console_iso_precision"] == Log.DEFAULT_LOG_SETTINGS["console_iso_precision"]
# Invalid console_format_type causes TypeError during handler creation
# because the code doesn't validate the type before using it
with pytest.raises(TypeError, match="'in <string>' requires string as left operand"):
Log(
log_path=tmp_log_path,
log_name="test",
log_settings=settings # type: ignore
)
# MARK: Test Spacer Constants
@@ -305,8 +228,7 @@ class TestParametrized:
("per_run_log", True, "not_bool"),
("console_enabled", False, 123),
("console_color_output_enabled", True, None),
("console_format_type", CONSOLE_FORMAT_TYPE_NORMAL, "invalid_format"),
("console_iso_precision", CONSOLE_ISO_TIME_MILLISECONDS, "invalid_precision"),
("console_format_type", ConsoleFormatSettings.ALL, "invalid_format"),
("add_start_info", False, []),
("add_end_info", True, {}),
])

View File

@@ -13,8 +13,7 @@ from corelibs.logging_handling.log import (
LogParent,
LogSettings,
CustomConsoleFormatter,
CONSOLE_FORMAT_TYPE_NORMAL,
CONSOLE_ISO_TIME_MILLISECONDS,
ConsoleFormatSettings,
)
from corelibs.logging_handling.logging_level_handling.logging_level import LoggingLevel
@@ -37,8 +36,7 @@ def basic_log_settings() -> LogSettings:
"per_run_log": False,
"console_enabled": True,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,
@@ -173,8 +171,7 @@ class TestLogInitialization:
"per_run_log": False,
"console_enabled": False,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,
@@ -196,8 +193,7 @@ class TestLogInitialization:
"per_run_log": True,
"console_enabled": False,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,
@@ -264,8 +260,7 @@ class TestLogInitialization:
"per_run_log": False,
"console_enabled": True,
"console_color_output_enabled": True,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,

View File

@@ -11,8 +11,7 @@ from corelibs.logging_handling.log import (
Log,
LogSettings,
CustomConsoleFormatter,
CONSOLE_FORMAT_TYPE_NORMAL,
CONSOLE_ISO_TIME_MILLISECONDS,
ConsoleFormatSettings,
)
from corelibs.logging_handling.logging_level_handling.logging_level import LoggingLevel
@@ -35,8 +34,7 @@ def basic_log_settings() -> LogSettings:
"per_run_log": False,
"console_enabled": True,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,

View File

@@ -11,8 +11,7 @@ from corelibs.logging_handling.log import (
Log,
LogSettings,
CustomHandlerFilter,
CONSOLE_FORMAT_TYPE_NORMAL,
CONSOLE_ISO_TIME_MILLISECONDS,
ConsoleFormatSettings,
)
from corelibs.logging_handling.logging_level_handling.logging_level import LoggingLevel
@@ -35,8 +34,7 @@ def basic_log_settings() -> LogSettings:
"per_run_log": False,
"console_enabled": True,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,

View File

@@ -11,8 +11,7 @@ from corelibs.logging_handling.log import (
Log,
LogParent,
LogSettings,
CONSOLE_FORMAT_TYPE_NORMAL,
CONSOLE_ISO_TIME_MILLISECONDS,
ConsoleFormatSettings,
)
from corelibs.logging_handling.logging_level_handling.logging_level import LoggingLevel
@@ -35,8 +34,7 @@ def basic_log_settings() -> LogSettings:
"per_run_log": False,
"console_enabled": True,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,
@@ -65,8 +63,7 @@ class TestHandlerManagement:
"per_run_log": False,
"console_enabled": False,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,

View File

@@ -10,8 +10,7 @@ from corelibs.logging_handling.log import (
Log,
Logger,
LogSettings,
CONSOLE_FORMAT_TYPE_NORMAL,
CONSOLE_ISO_TIME_MILLISECONDS,
ConsoleFormatSettings,
)
from corelibs.logging_handling.logging_level_handling.logging_level import LoggingLevel
@@ -34,8 +33,7 @@ def basic_log_settings() -> LogSettings:
"per_run_log": False,
"console_enabled": True,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,

View File

@@ -10,8 +10,7 @@ import pytest
from corelibs.logging_handling.log import (
Log,
LogSettings,
CONSOLE_FORMAT_TYPE_NORMAL,
CONSOLE_ISO_TIME_MILLISECONDS,
ConsoleFormatSettings,
)
from corelibs.logging_handling.logging_level_handling.logging_level import LoggingLevel
@@ -34,8 +33,7 @@ def basic_log_settings() -> LogSettings:
"per_run_log": False,
"console_enabled": True,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,
@@ -92,8 +90,7 @@ class TestEdgeCases:
"per_run_log": False,
"console_enabled": False,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": True, # Enable end info
"log_queue": None,

View File

@@ -12,8 +12,7 @@ import pytest
from corelibs.logging_handling.log import (
Log,
LogSettings,
CONSOLE_FORMAT_TYPE_NORMAL,
CONSOLE_ISO_TIME_MILLISECONDS,
ConsoleFormatSettings,
)
from corelibs.logging_handling.logging_level_handling.logging_level import LoggingLevel
@@ -36,8 +35,7 @@ def basic_log_settings() -> LogSettings:
"per_run_log": False,
"console_enabled": True,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": None,
@@ -72,8 +70,7 @@ class TestQueueListener:
"per_run_log": False,
"console_enabled": False,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": mock_queue, # type: ignore
@@ -109,8 +106,7 @@ class TestQueueListener:
"per_run_log": False,
"console_enabled": False,
"console_color_output_enabled": False,
"console_format_type": CONSOLE_FORMAT_TYPE_NORMAL,
"console_iso_precision": CONSOLE_ISO_TIME_MILLISECONDS,
"console_format_type": ConsoleFormatSettings.ALL,
"add_start_info": False,
"add_end_info": False,
"log_queue": mock_queue, # type: ignore