added coin API WS implementation

This commit is contained in:
Dobromir Popov
2025-08-08 01:00:38 +03:00
parent bd15bdc87d
commit ba532327b6
5 changed files with 165 additions and 8 deletions

View File

@ -292,4 +292,29 @@ def setup_logging(config: Optional[Config] = None):
log_config = config.logging
# Add separate error log with rotation and immediate flush
try:
from logging.handlers import RotatingFileHandler
error_log_dir = Path('logs')
error_log_dir.mkdir(parents=True, exist_ok=True)
error_log_path = error_log_dir / 'errors.log'
class FlushingErrorHandler(RotatingFileHandler):
def emit(self, record):
super().emit(record)
self.flush()
error_handler = FlushingErrorHandler(
str(error_log_path), maxBytes=10*1024*1024, backupCount=5, encoding='utf-8'
)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
error_handler.setFormatter(formatter)
error_handler.setLevel(logging.ERROR)
root_logger = logging.getLogger()
root_logger.addHandler(error_handler)
logger.info("Error log handler initialized at logs/errors.log")
except Exception as e:
logger.warning(f"Failed to initialize error log handler: {e}")
logger.info("Logging configured successfully with SafeFormatter")