Skip to content

Commit 61e2a27

Browse files
committed
added logging
1 parent 287f1df commit 61e2a27

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

utils.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
import pytz
55

66
from constants import MIN_SIDE_PADDING, SIDE_WHITE_SPACES, TIMEZONE, TITLE_LEN
7+
import logging
8+
9+
10+
logging.basicConfig(
11+
level=logging.INFO,
12+
format="%(asctime)s - %(levelname)s - %(message)s",
13+
)
714

815

916
class logger:
@@ -14,9 +21,9 @@ def log_title(title: str, title_len: int = TITLE_LEN):
1421
title_len, len(title) + MIN_SIDE_PADDING * 2 + SIDE_WHITE_SPACES * 2
1522
)
1623

17-
print(
18-
f"{SIDE_WHITE_SPACES * ' ' + title + ' ' * SIDE_WHITE_SPACES:=^{final_len}}"
19-
)
24+
formatted = f"{SIDE_WHITE_SPACES * ' ' + title + ' ' * SIDE_WHITE_SPACES:=^{final_len}}"
25+
logging.info(formatted)
26+
2027

2128
@staticmethod
2229
def log_to_csv(csv_name: str, field_names: tuple[str], row: dict | None = None):
@@ -33,20 +40,19 @@ def log_to_csv(csv_name: str, field_names: tuple[str], row: dict | None = None):
3340

3441
@staticmethod
3542
def log_to_stdout(info: dict):
36-
print(info)
43+
logging.info(f"{info}")
3744

3845
@staticmethod
3946
def log_sep():
40-
print("-" * TITLE_LEN)
47+
logging.info("-" * TITLE_LEN)
4148

4249
@staticmethod
4350
def log_error(error: str):
44-
# или использовать logging, как в interface_wrapper
45-
pass
51+
logging.error(error)
4652

4753
@staticmethod
4854
def log_warning(warning: str):
49-
pass
55+
logging.warning(warning)
5056

5157

5258
def parse_time(datetime_str) -> datetime:

0 commit comments

Comments
 (0)