added coin API WS implementation
This commit is contained in:
@ -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")
|
||||
|
Reference in New Issue
Block a user