forked from kodorvan/stcs
		
	
		
			
				
	
	
		
			150 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			150 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
import os
 | 
						|
 | 
						|
current_directory = os.path.dirname(os.path.abspath(__file__))
 | 
						|
log_directory = os.path.join(current_directory, 'loggers')
 | 
						|
error_log_directory = os.path.join(log_directory, 'errors')
 | 
						|
os.makedirs(log_directory, exist_ok=True)
 | 
						|
os.makedirs(error_log_directory, exist_ok=True)
 | 
						|
log_filename = os.path.join(log_directory, 'app.log')
 | 
						|
error_log_filename = os.path.join(error_log_directory, 'error.log')
 | 
						|
 | 
						|
LOGGING_CONFIG = {
 | 
						|
    "version": 1,
 | 
						|
    "disable_existing_loggers": False,
 | 
						|
    "formatters": {
 | 
						|
        "default": {
 | 
						|
            "format": "TELEGRAM: %(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",
 | 
						|
            "level": "DEBUG",
 | 
						|
        },
 | 
						|
        "error_file": {
 | 
						|
            "class": "logging.handlers.TimedRotatingFileHandler",
 | 
						|
            "filename": error_log_filename,
 | 
						|
            "when": "midnight",
 | 
						|
            "interval": 1,
 | 
						|
            "backupCount": 30,
 | 
						|
            "formatter": "default",
 | 
						|
            "encoding": "utf-8",
 | 
						|
            "level": "ERROR",
 | 
						|
        },
 | 
						|
        "console": {
 | 
						|
            "class": "logging.StreamHandler",
 | 
						|
            "formatter": "default",
 | 
						|
            "level": "DEBUG",
 | 
						|
        },
 | 
						|
    },
 | 
						|
    "loggers": {
 | 
						|
        "run": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "config": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "common": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "handlers_main": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "database": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "request": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "add_bybit_api": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "profile_tg": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "settings": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "additional_settings": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "helper_functions": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "risk_management": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "start_trading": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "stop_trading": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "changing_the_symbol": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "conditional_settings": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "get_positions_handlers": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "close_orders": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "tp_sl_handlers": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
        "tasks": {
 | 
						|
            "handlers": ["console", "timed_rotating_file", "error_file"],
 | 
						|
            "level": "DEBUG",
 | 
						|
            "propagate": False,
 | 
						|
        },
 | 
						|
    },
 | 
						|
}
 |