Skip to content

Commit

Permalink
Define logger as global variable with level set to WARNING; it can be…
Browse files Browse the repository at this point in the history
… overridden in conf.py
  • Loading branch information
JasperCraeghs committed Aug 23, 2024
1 parent 89ae364 commit 5e97c3b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mlx/coverity_logging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""Module to provide functions that accommodate logging."""

from sphinx.util.logging import getLogger
from logging import WARNING

LOGGER = getLogger(__name__)
LOGGER.setLevel(WARNING)


def report_warning(msg, docname, lineno=None):
Expand All @@ -11,11 +15,10 @@ def report_warning(msg, docname, lineno=None):
docname (str): Name of the document in which the error occurred
lineno (str): Line number in the document on which the error occurred
"""
logger = getLogger(__name__)
if lineno is not None:
logger.warning(msg, location=(docname, lineno))
LOGGER.warning(msg, location=(docname, lineno))
else:
logger.warning(msg, location=docname)
LOGGER.warning(msg, location=docname)


def report_info(msg, nonl=False):
Expand All @@ -25,5 +28,4 @@ def report_info(msg, nonl=False):
msg (str): Message of the warning
nonl (bool): True when no new line at end
"""
logger = getLogger(__name__)
logger.info(msg, nonl=nonl)
LOGGER.info(msg, nonl=nonl)

0 comments on commit 5e97c3b

Please sign in to comment.