Skip to content

Commit

Permalink
move trace func to logger.py, fix format in appledict_bin
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Jan 2, 2025
1 parent e10bf9c commit 2fbb656
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
15 changes: 1 addition & 14 deletions pyglossary/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@
isfile,
join,
)
from typing import TYPE_CHECKING

from . import logger
from .logger import TRACE

if TYPE_CHECKING:
import logging
from .logger import TRACE, trace


def exc_note(e: Exception, note: str) -> Exception:
Expand Down Expand Up @@ -60,18 +56,9 @@ def exc_note(e: Exception, note: str) -> Exception:

homePage = "https://github.com/ilius/pyglossary"


noColor = False


def trace(log: logging.Logger, msg: str) -> None:
func = getattr(log, "trace", None)
if func is None:
log.error(f"Logger {log} has no 'trace' method")
return
func(msg)


def checkCreateConfDir() -> None:
if not isdir(confDir):
if exists(confDir): # file, or anything other than directory
Expand Down
8 changes: 8 additions & 0 deletions pyglossary/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
logging.addLevelName(TRACE, "TRACE")


def trace(log: logging.Logger, msg: str) -> None:
func = getattr(log, "trace", None)
if func is None:
log.error(f"Logger {log} has no 'trace' method")
return
func(msg)


class _Formatter(logging.Formatter):
def __init__(self, *args, **kwargs) -> None: # noqa: ANN002, ANN003
logging.Formatter.__init__(self, *args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion pyglossary/plugins/appledict_bin/key_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import typing

if typing.TYPE_CHECKING:
from collections.abc import Sequence
from collections.abc import Sequence

__all__ = ["KeyData", "RawKeyData"]

Expand Down

0 comments on commit 2fbb656

Please sign in to comment.