Skip to content

Commit

Permalink
cleanup logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jschlyter committed Oct 21, 2024
1 parent 0533f67 commit 667f8f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions dnstapir/logging.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging.config
from datetime import datetime

from jsonformatter import JsonFormatter as _JsonFormatter
Expand Down Expand Up @@ -42,3 +43,7 @@ class JsonFormatter(_JsonFormatter):
def formatTime(self, record, datefmt=None):
dt = datetime.fromtimestamp(record.created).astimezone()
return dt.strftime(TIMESTAMP_FORMAT)


def configure_json_logging():
logging.config.dictConfig(LOGGING_CONFIG_JSON)
8 changes: 3 additions & 5 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import logging
import logging.config

from dnstapir.logging import LOGGING_CONFIG_JSON
from dnstapir.logging import configure_json_logging


def test_logging():
configure_json_logging()
logger = logging.getLogger(__name__)
logging_config = LOGGING_CONFIG_JSON
logging.config.dictConfig(logging_config)
logger.warning("Hello")
logger.warning("Hello world")

0 comments on commit 667f8f5

Please sign in to comment.