package cn.novalon.gym.manage.common.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

/**
 * 默认异常日志服务实现
 * 临时实现，用于解决启动时的依赖注入问题
 * 
 * @author 张翔
 * @date 2026-04-15
 */
@Service
public class DefaultExceptionLogService implements IExceptionLogService {

    private static final Logger logger = LoggerFactory.getLogger(DefaultExceptionLogService.class);

    @Override
    public Mono<Void> logException(String title, String exceptionName, String exceptionMsg, 
                                 String methodName, String ip, String stackTrace) {
        logger.warn("异常日志记录 (临时实现): title={}, exceptionName={}, methodName={}, ip={}", 
                   title, exceptionName, methodName, ip);
        logger.warn("异常信息: {}", exceptionMsg);
        if (stackTrace != null && stackTrace.length() > 500) {
            logger.warn("堆栈跟踪 (截断): {}", stackTrace.substring(0, 500) + "...");
        } else if (stackTrace != null) {
            logger.warn("堆栈跟踪: {}", stackTrace);
        }
        return Mono.empty();
    }
}