Skip to content

Commit

Permalink
Merge pull request #33 from openweathermap/feature/logger-format
Browse files Browse the repository at this point in the history
logger
  • Loading branch information
matveyvarg authored Dec 29, 2023
2 parents d3f5336 + 3e61df8 commit 85028d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion deker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

from deker_tools.data import convert_size_to_human
from deker_tools.path import is_path_valid
from deker_tools.log import set_logger
from psutil import swap_memory, virtual_memory
from tqdm import tqdm

Expand All @@ -42,7 +43,7 @@
)
from deker.integrity import IntegrityChecker
from deker.locks import META_DIVIDER
from deker.log import SelfLoggerMixin, set_logging_level
from deker.log import SelfLoggerMixin, set_logging_level, format_string
from deker.schemas import ArraySchema, VArraySchema
from deker.tools import convert_human_memory_to_bytes
from deker.types import ArrayLockMeta, CollectionLockMeta, LocksExtensions, LocksTypes, StorageSize
Expand Down Expand Up @@ -212,6 +213,7 @@ def __init__(
:param kwargs: a wildcard, reserved for any extra parameters
"""
try:
set_logger(format_string)
set_logging_level(loglevel.upper())
self.__get_plugins()
total_available_mem = virtual_memory().total + swap_memory().total
Expand Down
8 changes: 5 additions & 3 deletions deker/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@

from logging import Logger


_ROOT_DEKER_LOGGER_NAME = "Deker"
_level = os.getenv("DEKER_LOGLEVEL", "WARNING")
_format = "%(name)s %(levelname)-4s [%(asctime)s] %(message)s"

format_string = "%(levelname)s | %(asctime)s | %(name)s | %(message)s"
fmter = logging.Formatter(fmt=format_string)

_logger = logging.getLogger(_ROOT_DEKER_LOGGER_NAME)
_handler = logging.StreamHandler()
_handler.setFormatter(logging.Formatter(fmt=_format))
_handler.setFormatter(fmter)
_logger.addHandler(_handler)


Expand Down

0 comments on commit 85028d1

Please sign in to comment.