Skip to content

Commit

Permalink
Move logging from conf.py to setup(app); Default WARNING level
Browse files Browse the repository at this point in the history
  • Loading branch information
JokeWaumans committed Sep 4, 2024
1 parent b08f5c8 commit 7adced4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
11 changes: 1 addition & 10 deletions example/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
import sys

import mlx.coverity
from mlx.coverity import __version__, coverity_logging
from mlx.coverity import __version__
import mlx.traceability
from decouple import config
import logging

pkg_version = __version__

Expand Down Expand Up @@ -320,11 +319,3 @@
TRACEABILITY_ITEM_ID_REGEX = r"([A-Z_]+-[A-Z0-9_]+)"
TRACEABILITY_ITEM_RELINK = {}

log_level = os.environ.get('LOGLEVEL', None)
if log_level:
try:
numeric_level = getattr(logging, log_level.upper(), None)
coverity_logging.LOGGER.setLevel(level=numeric_level)
except:
raise ValueError(f"Invalid log level: {log_level}")

12 changes: 11 additions & 1 deletion mlx/coverity/coverity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
"""

from getpass import getpass
import logging
import os
from sphinx.util.logging import getLogger
from urllib.error import URLError, HTTPError

from docutils import nodes

from .__coverity_version__ import __version__
from .coverity_logging import report_info, report_warning
from .coverity_logging import report_info, report_warning, LOGGER
from .coverity_services import CoverityDefectService
from .coverity_directives.coverity_defect_list import (
CoverityDefect,
Expand Down Expand Up @@ -159,6 +162,13 @@ def get_filtered_defects(self, node):
# Extension setup
def setup(app):
"""Extension setup"""
log_level = os.environ.get('LOGLEVEL', "WARNING")
try:
numeric_level = getattr(logging, log_level.upper())
LOGGER.setLevel(numeric_level)
except:
raise ValueError(f"Invalid log level: {log_level}")

# Create default configuration. Can be customized in conf.py
app.add_config_value(
"coverity_credentials",
Expand Down
2 changes: 0 additions & 2 deletions mlx/coverity/coverity_logging.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""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 Down

0 comments on commit 7adced4

Please sign in to comment.