Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/daqpytools/logging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from daqpytools.logging.handlerconf import HandlerType, LogHandlerConf
from daqpytools.logging.handlers import add_handler
from daqpytools.logging.levels import logging_log_levels
from daqpytools.logging.logger import (
get_daq_logger,
setup_daq_ers_logger,
setup_root_logger,
)
from daqpytools.logging.formatter import DAQ_CONSOLE

Check failure on line 9 in src/daqpytools/logging/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

src/daqpytools/logging/__init__.py:1:1: I001 Import block is un-sorted or un-formatted help: Organize imports

__all__ = [
"HandlerType",
"LogHandlerConf",
"add_handler",
"get_daq_logger",
"logging_log_levels",
"setup_daq_ers_logger",
"setup_root_logger",
"DAQ_CONSOLE",
]

Check failure on line 20 in src/daqpytools/logging/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (RUF022)

src/daqpytools/logging/__init__.py:11:11: RUF022 `__all__` is not sorted help: Apply an isort-style sorting to `__all__`
7 changes: 7 additions & 0 deletions src/daqpytools/logging/formatter.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import configparser
import logging
import os
import re
from copy import copy
from datetime import datetime, tzinfo
from pathlib import Path

from rich.console import Console

from pytz import UnknownTimeZoneError, timezone
from rich.theme import Theme

from daqpytools.logging.exceptions import LoggerConfigurationError

Check failure on line 14 in src/daqpytools/logging/formatter.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

src/daqpytools/logging/formatter.py:1:1: I001 Import block is un-sorted or un-formatted help: Organize imports

DAQPYTOOLS_LOGGING_ROOT = Path(os.path.abspath(__file__)).parent
CONFIGURATION_FILE = DAQPYTOOLS_LOGGING_ROOT / "log_format.ini"
Expand Down Expand Up @@ -131,3 +133,8 @@
formatted_record.name = f"{formatted_record.name}".ljust(padding)[:padding]

return super().format(formatted_record)

## Single console instance
DAQ_CONSOLE = Console(
force_terminal=True, theme=CONSOLE_THEME
)
7 changes: 3 additions & 4 deletions src/daqpytools/logging/rich_handler.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
from __future__ import annotations

import logging
from datetime import datetime

from rich.console import Console, ConsoleRenderable
from rich.console import ConsoleRenderable, Console
from rich.logging import RichHandler
from rich.text import Text

from daqpytools.logging.formatter import (
CONSOLE_THEME,
DATE_TIME_FORMAT,
LOG_RECORD_PADDING,
TIME_ZONE,
DAQ_CONSOLE
)
from daqpytools.logging.levels import logging_log_level_to_str

Check failure on line 17 in src/daqpytools/logging/rich_handler.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

src/daqpytools/logging/rich_handler.py:1:1: I001 Import block is un-sorted or un-formatted help: Organize imports


class FormattedRichHandler(RichHandler):
Expand All @@ -21,9 +22,7 @@

def __init__(self, width: int = 100) -> None:
"""Initialize with custom console and style settings."""
console: Console = Console(
force_terminal=True, width=width, theme=CONSOLE_THEME
)
console: Console = DAQ_CONSOLE
super().__init__(
console=console,
omit_repeated_times=False,
Expand Down
Loading