Skip to content

Commit

Permalink
Debug logging configuration (load at runtime)
Browse files Browse the repository at this point in the history
  • Loading branch information
sHermanGriffiths committed Nov 9, 2024
1 parent 248b668 commit 3c88f77
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
18 changes: 18 additions & 0 deletions n2y/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import logging
import os


def filter_log(record: logging.LogRecord) -> logging.LogRecord:
record.pathname = record.pathname.replace(os.getcwd() + "/", "")
return record


FORMATTER = logging.Formatter(
"%(asctime)s - %(levelname)s (%(pathname)s::%(funcName)s::%(lineno)d): %(message)s"
)
HANDLER = logging.StreamHandler()
HANDLER.setLevel(logging.INFO)
HANDLER.setFormatter(FORMATTER)
HANDLER.addFilter(filter_log)
LOG = logging.getLogger(__name__)
LOG.addHandler(HANDLER)
17 changes: 0 additions & 17 deletions n2y/logger.py

This file was deleted.

2 changes: 1 addition & 1 deletion n2y/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main(raw_args, access_token, n2y_cache=None, logger=log):
args = parser.parse_args(raw_args)

logging_level = logging.__dict__[args.verbosity]
logger.setLevel(logging_level)
logging.basicConfig(level=logging_level)

if n2y_cache is not None:
try:
Expand Down

0 comments on commit 3c88f77

Please sign in to comment.