Skip to content

Commit

Permalink
Make logging opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
sondrelg committed Jun 29, 2021
1 parent 9385667 commit 9784518
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions sanity_html/logger.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""
Logging setup.
The rest of the code gets the logger through this module rather than
`logging.getLogger` to make sure that it is configured.
"""
import logging
import sys

logger = logging.getLogger('sanity_html')

# Make logger output to stdout
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
if not logger.handlers: # pragma: no cover
logger.setLevel(logging.WARNING)
logger.addHandler(logging.NullHandler())

0 comments on commit 9784518

Please sign in to comment.