package com.lanyuanxiaoyao.service.info.controller;

import com.lanyuanxiaoyao.service.configuration.entity.info.SQLLine;
import com.lanyuanxiaoyao.service.info.configuration.SQLLoggerProvider;
import org.eclipse.collections.api.list.ImmutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Sql 日志
 *
 * @author lanyuanxiaoyao
 * @date 2023-07-11
 */
@RestController
@RequestMapping("logs")
public class LogController {
    private static final Logger logger = LoggerFactory.getLogger(LogController.class);

    private final SQLLoggerProvider.SQLLogger sqlLogger;

    public LogController(SQLLoggerProvider.SQLLogger sqlLogger) {
        this.sqlLogger = sqlLogger;
    }

    @GetMapping("")
    public ImmutableList<SQLLine> logs() {
        return sqlLogger.getLogs();
    }
}
