package com.cool.bang.modules.system.controller;

import com.cool.bang.common.base.BaseController;
import com.cool.bang.common.web.response.Result;
import com.cool.bang.modules.system.service.ILoggerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 页面日志
 *
 * @author PeiZhi Guo
 * 2023/10/25 19:35
 */
@RestController
@RequestMapping("/system/logger")
public class LoggerController extends BaseController {

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

    private ILoggerService loggerService;

    @Autowired
    public LoggerController(ILoggerService loggerService) {
        this.loggerService = loggerService;
    }

    /**
     * 获取日志
     */
    @GetMapping("servers")
    public Result logger(String level, Integer count, String date) {
       if (count == null) {
           count = 1000;
       }
       return success("操作成功", loggerService.readLoggers(level, count, date));
    }

}
