Skip to content
Snippets Groups Projects
Commit fe7e0920 authored by Bert Palm's avatar Bert Palm 🎇
Browse files

fixed logging, added debug message indicates the test that run.

i removed the setup of the logging module from the core. It interferes
with the needs of the user of the lib (saqc). eg. Messages are double
printed or not at all.

>> It is strongly advised that you do not add any handlers other than
>> NullHandler to your library’s loggers. [...]
from https://docs.python.org/3/howto/logging.html

we might add a defalutLoggingSetup(log_level='INFO') function or similar in future,
to ease the setup the logging.
parent 1430d358
No related branches found
No related tags found
2 merge requests!193Release 1.4,!188Release 1.4
Pipeline #5812 passed with stage
in 6 minutes and 44 seconds
......@@ -5,13 +5,16 @@ import click
import numpy as np
import pandas as pd
import logging
from saqc.core import SaQC, logger
from saqc.core import SaQC
from saqc.flagger import CategoricalFlagger
from saqc.flagger.dmpflagger import DmpFlagger
import dios
logger = logging.getLogger("SaQC")
FLAGGERS = {
"numeric": CategoricalFlagger([-1, 0, 1]),
"category": CategoricalFlagger(["NIL", "OK", "BAD"]),
......@@ -19,6 +22,14 @@ FLAGGERS = {
}
def _setup_logging(loglvl):
logger.setLevel(loglvl)
handler = logging.StreamHandler()
formatter = logging.Formatter("[%(asctime)s][%(name)s][%(levelname)s]: %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
@click.command()
@click.option(
"-c", "--config", type=click.Path(exists=True), required=True, help="path to the configuration file",
......@@ -37,7 +48,7 @@ FLAGGERS = {
@click.option("--fail/--no-fail", default=True, help="whether to stop the program run on errors")
def main(config, data, flagger, outfile, nodata, log_level, fail):
logger.setLevel(log_level)
_setup_logging(log_level)
data = pd.read_csv(data, index_col=0, parse_dates=True,)
data = dios.DictOfSeries(data)
......
......@@ -90,13 +90,6 @@ def _setup():
pd.set_option("mode.chained_assignment", "warn")
np.seterr(invalid="ignore")
# logging
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter("[%(asctime)s][%(name)s][%(levelname)s]: %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
_setup()
......@@ -157,6 +150,7 @@ class SaQC:
data, flagger = self._data, self._flagger
for field, func in self._to_call:
logger.debug(f"processing: {field}, {func.__name__}, {func.kwargs}")
try:
data_result, flagger_result = func(data=data, flagger=flagger, field=field)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment