Skip to content

Commit

Permalink
Reduce logging level for several imported modules
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodsf committed Jan 10, 2025
1 parent e04ba96 commit ba306d3
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
6 changes: 2 additions & 4 deletions sourcespec/savefig.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
import warnings
from PIL import Image
# Reduce logging level for PIL to avoid DEBUG messages
pil_logger = logging.getLogger('PIL')
pil_logger.setLevel(logging.WARNING)
logging.getLogger('PIL').setLevel(logging.WARNING)
# Reduce logging level for fontTools to avoid DEBUG messages
mpl_logger = logging.getLogger('fontTools')
mpl_logger.setLevel(logging.WARNING)
logging.getLogger('fontTools').setLevel(logging.WARNING)
# Silence PIL warnings about transparency needing RGBA, since we remove the
# alpha channel anyway (see below)
warnings.filterwarnings('ignore', message='Palette images with Transparency')
Expand Down
7 changes: 6 additions & 1 deletion sourcespec/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
import copy
import fnmatch
import warnings
import logging
import math
import h5py
import yaml
import numpy as np
# Reduce logging loevel for h5py.
# For h5py, this has to be done before importing the module.
logging.getLogger('h5py').setLevel(logging.WARNING)
# pylint: disable=wrong-import-position
import h5py # noqa: E402


def signal_fft(signal, delta):
Expand Down
2 changes: 2 additions & 0 deletions sourcespec/ssp_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from sourcespec.ssp_sqlite_output import write_sqlite
from sourcespec._version import get_versions
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# reduce logging level for tzlocal
logging.getLogger('tzlocal').setLevel(logging.WARNING)


def _write_author_and_agency_to_parfile(config, parfile):
Expand Down
3 changes: 1 addition & 2 deletions sourcespec/ssp_plot_params_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
from sourcespec.savefig import savefig
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# Reduce logging level for Matplotlib to avoid DEBUG messages
mpl_logger = logging.getLogger('matplotlib')
mpl_logger.setLevel(logging.WARNING)
logging.getLogger('matplotlib').setLevel(logging.WARNING)


class PlotParam():
Expand Down
3 changes: 1 addition & 2 deletions sourcespec/ssp_plot_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
from sourcespec._version import get_versions
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# Reduce logging level for Matplotlib to avoid DEBUG messages
mpl_logger = logging.getLogger('matplotlib')
mpl_logger.setLevel(logging.WARNING)
logging.getLogger('matplotlib').setLevel(logging.WARNING)


synth_colors = [
Expand Down
3 changes: 1 addition & 2 deletions sourcespec/ssp_plot_stacked_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
from sourcespec._version import get_versions
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# Reduce logging level for Matplotlib to avoid DEBUG messages
mpl_logger = logging.getLogger('matplotlib')
mpl_logger.setLevel(logging.WARNING)
logging.getLogger('matplotlib').setLevel(logging.WARNING)


def _spectral_model_moment(freq, Mw, fc, t_star):
Expand Down
5 changes: 3 additions & 2 deletions sourcespec/ssp_plot_stations.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
from sourcespec._version import get_versions
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# Reduce logging level for Matplotlib to avoid DEBUG messages
mpl_logger = logging.getLogger('matplotlib')
mpl_logger.setLevel(logging.WARNING)
logging.getLogger('matplotlib').setLevel(logging.WARNING)
# Reduce logging level for pyproj to avoid DEBUG messages
logging.getLogger('pyproj').setLevel(logging.WARNING)
# The following code fails with Sphinx and with Shapely<1,8, so we need to
# ignore any exception
with contextlib.suppress(Exception):
Expand Down
3 changes: 1 addition & 2 deletions sourcespec/ssp_plot_traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
from sourcespec._version import get_versions
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])
# Reduce logging level for Matplotlib to avoid DEBUG messages
mpl_logger = logging.getLogger('matplotlib')
mpl_logger.setLevel(logging.WARNING)
logging.getLogger('matplotlib').setLevel(logging.WARNING)


class ScalarFormatter(sf):
Expand Down

0 comments on commit ba306d3

Please sign in to comment.