Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import pytz

from constants import MIN_SIDE_PADDING, SIDE_WHITE_SPACES, TIMEZONE, TITLE_LEN
import logging


logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
)


class logger:
Expand All @@ -14,9 +21,8 @@ def log_title(title: str, title_len: int = TITLE_LEN):
title_len, len(title) + MIN_SIDE_PADDING * 2 + SIDE_WHITE_SPACES * 2
)

print(
f"{SIDE_WHITE_SPACES * ' ' + title + ' ' * SIDE_WHITE_SPACES:=^{final_len}}"
)
formatted = f"{SIDE_WHITE_SPACES * ' ' + title + ' ' * SIDE_WHITE_SPACES:=^{final_len}}"
logging.info(formatted)

@staticmethod
def log_to_csv(csv_name: str, field_names: tuple[str], row: dict | None = None):
Expand All @@ -33,20 +39,19 @@ def log_to_csv(csv_name: str, field_names: tuple[str], row: dict | None = None):

@staticmethod
def log_to_stdout(info: dict):
print(info)
logging.info(f"{info}")

@staticmethod
def log_sep():
print("-" * TITLE_LEN)
logging.info("-" * TITLE_LEN)

@staticmethod
def log_error(error: str):
# или использовать logging, как в interface_wrapper
pass
logging.error(error)

@staticmethod
def log_warning(warning: str):
pass
logging.warning(warning)


def parse_time(datetime_str) -> datetime:
Expand Down
Loading