Skip to content

Commit

Permalink
logging: use 'kioss' LOGGER instead og root one
Browse files Browse the repository at this point in the history
  • Loading branch information
ebonnal committed Nov 30, 2023
1 parent 106c51e commit d362e6d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 5 additions & 0 deletions kioss/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
from kioss._plan import SourcePipe as Pipe

import logging

LOGGER = logging.getLogger("kioss")
LOGGER.setLevel(logging.INFO)
8 changes: 3 additions & 5 deletions kioss/_exec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging
import time
from datetime import datetime
from typing import (
Expand All @@ -14,7 +13,7 @@
T = TypeVar("T")
R = TypeVar("R")

from kioss import _util
from kioss import _util, LOGGER


class IteratorWrapper(Iterator[T]):
Expand Down Expand Up @@ -58,11 +57,10 @@ def __init__(self, iterator: Iterator[T], what: str) -> None:
self.errors_count = 0
self.last_log_at_yields_count = None
self.start_time = time.time()
logging.getLogger().setLevel(logging.INFO)
logging.info("iteration over '%s' will be logged.", self.what)
LOGGER.info("iteration over '%s' will be logged.", self.what)

def _log(self) -> None:
logging.info(
LOGGER.info(
"%s `%s` have been yielded in elapsed time '%s' with %s errors produced",
self.yields_count,
self.what,
Expand Down
7 changes: 3 additions & 4 deletions kioss/_plan.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import itertools
import logging
from abc import ABC, abstractmethod
from typing import (
Any,
Expand All @@ -13,7 +12,7 @@
TypeVar,
)

from kioss import _exec, _concurrent_exec, _util
from kioss import _exec, _concurrent_exec, _util, LOGGER

T = TypeVar("T")
R = TypeVar("R")
Expand All @@ -25,7 +24,7 @@ def __init__(self, upstream: "Optional[APipe[T]]" = None):

@abstractmethod
def __iter__(self) -> Iterator[T]:
raise NotImplemented()
raise NotImplemented() # TODO: Visitor pattern

def __add__(self, other: "APipe[T]") -> "APipe[T]":
return self.chain(other)
Expand Down Expand Up @@ -226,7 +225,7 @@ def register_error_sample(error):
n_samples=n_samples
)
if errors_count > 0:
logging.error(
LOGGER.error(
"first %s error samples: %s\nWill now raise the first of them:",
n_error_samples,
list(map(repr, error_samples)),
Expand Down

0 comments on commit d362e6d

Please sign in to comment.