forked from kodorvan/stcs
The entire database has been changed to PostgresSQL. The entire code has been updated.
This commit is contained in:
129
app/bybit/logger_bybit/logger_bybit.py
Normal file
129
app/bybit/logger_bybit/logger_bybit.py
Normal file
@@ -0,0 +1,129 @@
|
||||
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": "BYBIT: %(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": {
|
||||
"profile_bybit": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"get_balance": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"price_symbol": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"bybit": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"web_socket": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"get_tickers": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"set_margin_mode": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"set_switch_margin_mode": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"set_switch_position_mode": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"set_leverage": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"get_instruments_info": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"get_positions": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"open_positions": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"close_positions": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"telegram_message_handler": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
"set_tp_sl": {
|
||||
"handlers": ["console", "timed_rotating_file", "error_file"],
|
||||
"level": "DEBUG",
|
||||
"propagate": False,
|
||||
},
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user