diff --git a/logger_helper/logger_helper.py b/logger_helper/logger_helper.py new file mode 100644 index 0000000..8ff88be --- /dev/null +++ b/logger_helper/logger_helper.py @@ -0,0 +1,84 @@ +import os + +current_directory = os.path.dirname(os.path.abspath(__file__)) +log_directory = os.path.join(current_directory, 'loggers') +os.makedirs(log_directory, exist_ok=True) +log_filename = os.path.join(log_directory, 'app.log') + +LOGGING_CONFIG = { + "version": 1, + "disable_existing_loggers": False, + "formatters": { + "default": { + "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s", + "datefmt": "%Y-%m-%d %H:%M:%S", # Формат даты + }, + }, + "handlers": { + "timed_rotating_file": { + "class": "logging.handlers.TimedRotatingFileHandler", + "filename": log_filename, + "when": "midnight", # Время ротации (каждую полночь) + "interval": 1, # Интервал в днях + "backupCount": 7, # Количество сохраняемых архивов (0 - не сохранять) + "formatter": "default", + "encoding": "utf-8", + }, + "console": { + "class": "logging.StreamHandler", + "formatter": "default", + }, + }, + "loggers": { + "main": { + "handlers": ["console", "timed_rotating_file"], + "level": "DEBUG", + "propagate": False, + }, + "add_bybit_api": { + "handlers": ["console", "timed_rotating_file"], + "level": "DEBUG", + "propagate": False, + }, + "balance": { + "handlers": ["console", "timed_rotating_file"], + "level": "DEBUG", + "propagate": False, + }, + "functions": { + "handlers": ["console", "timed_rotating_file"], + "level": "DEBUG", + "propagate": False, + }, + "futures": { + "handlers": ["console", "timed_rotating_file"], + "level": "DEBUG", + "propagate": False, + }, + "get_valid_symbol": { + "handlers": ["console", "timed_rotating_file"], + "level": "DEBUG", + "propagate": False, + }, + "min_qty": { + "handlers": ["console", "timed_rotating_file"], + "level": "DEBUG", + "propagate": False, + }, + "price_symbol": { + "handlers": ["console", "timed_rotating_file"], + "level": "DEBUG", + "propagate": False, + }, + "requests": { + "handlers": ["console", "timed_rotating_file"], + "level": "DEBUG", + "propagate": False, + }, + "handlers": { + "handlers": ["console", "timed_rotating_file"], + "level": "DEBUG", + "propagate": False, + }, + }, +}