使用Slf4j注解打印日志

This commit is contained in:
648540858
2024-07-03 17:24:35 +08:00
parent adf040ec4b
commit b98cfd1fed
66 changed files with 804 additions and 1039 deletions

View File

@@ -5,8 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -20,13 +19,11 @@ import java.text.ParseException;
/**
* API兼容设备控制
*/
@Slf4j
@RestController
@RequestMapping(value = "/api/v1/control")
public class ApiControlController {
private final static Logger logger = LoggerFactory.getLogger(ApiControlController.class);
@Autowired
private SIPCommander cmder;
@@ -48,8 +45,8 @@ public class ApiControlController {
@RequestParam(required = false)String code,
@RequestParam(required = false)Integer speed){
if (logger.isDebugEnabled()) {
logger.debug("模拟接口> 设备云台控制 API调用deviceId{} channelId{} command{} speed{} ",
if (log.isDebugEnabled()) {
log.debug("模拟接口> 设备云台控制 API调用deviceId{} channelId{} command{} speed{} ",
serial, code, command, speed);
}
if (channel == null) {channel = 0;}
@@ -100,7 +97,7 @@ public class ApiControlController {
try {
cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 云台控制: {}", e.getMessage());
log.error("[命令发送失败] 云台控制: {}", e.getMessage());
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
}
}
@@ -122,8 +119,8 @@ public class ApiControlController {
@RequestParam(required = false)String name,
@RequestParam(required = false)Integer preset){
if (logger.isDebugEnabled()) {
logger.debug("模拟接口> 预置位控制 API调用deviceId{} channelId{} command{} name{} preset{} ",
if (log.isDebugEnabled()) {
log.debug("模拟接口> 预置位控制 API调用deviceId{} channelId{} command{} name{} preset{} ",
serial, code, command, name, preset);
}
@@ -149,7 +146,7 @@ public class ApiControlController {
try {
cmder.frontEndCmd(device, code, cmdCode, 0, preset, 0);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[命令发送失败] 预置位控制: {}", e.getMessage());
log.error("[命令发送失败] 预置位控制: {}", e.getMessage());
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
}
}

View File

@@ -2,8 +2,7 @@ package com.genersoft.iot.vmp.web.gb28181;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.conf.SipConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@@ -14,12 +13,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
* API兼容系统接口
*/
@Controller
@Slf4j
@RequestMapping(value = "/api/v1")
public class ApiController {
private final static Logger logger = LoggerFactory.getLogger(ApiController.class);
@Autowired
private SipConfig sipConfig;
@@ -87,8 +84,8 @@ public class ApiController {
@GetMapping(value = "/login")
@ResponseBody
private JSONObject login(String username,String password ){
if (logger.isDebugEnabled()) {
logger.debug(String.format("模拟接口> 登录 API调用username%s password%s ",
if (log.isDebugEnabled()) {
log.debug(String.format("模拟接口> 登录 API调用username%s password%s ",
username, password));
}

View File

@@ -14,8 +14,7 @@ import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
@@ -33,13 +32,11 @@ import java.util.*;
* API兼容设备信息
*/
@SuppressWarnings("unchecked")
@Slf4j
@RestController
@RequestMapping(value = "/api/v1/device")
public class ApiDeviceController {
private final static Logger logger = LoggerFactory.getLogger(ApiDeviceController.class);
@Autowired
private IVideoManagerStorage storager;
@@ -194,8 +191,8 @@ public class ApiDeviceController {
@RequestParam(required = false)Boolean fill,
@RequestParam(required = false)Integer timeout){
if (logger.isDebugEnabled()) {
logger.debug("<模拟接口> 获取下级通道预置位 API调用deviceId{} channel{} code{} fill{} timeout{} ",
if (log.isDebugEnabled()) {
log.debug("<模拟接口> 获取下级通道预置位 API调用deviceId{} channel{} code{} fill{} timeout{} ",
serial, channel, code, fill, timeout);
}
@@ -205,7 +202,7 @@ public class ApiDeviceController {
DeferredResult<Object> result = new DeferredResult<> (timeout * 1000L);
DeferredResultEx<Object> deferredResultEx = new DeferredResultEx<>(result);
result.onTimeout(()->{
logger.warn("<模拟接口> 获取设备预置位超时");
log.warn("<模拟接口> 获取设备预置位超时");
// 释放rtpserver
RequestMessage msg = new RequestMessage();
msg.setId(uuid);
@@ -246,7 +243,7 @@ public class ApiDeviceController {
resultHolder.invokeResult(msg);
});
} catch (InvalidArgumentException | SipException | ParseException e) {
logger.error("[命令发送失败] 获取设备预置位: {}", e.getMessage());
log.error("[命令发送失败] 获取设备预置位: {}", e.getMessage());
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
}
return result;

View File

@@ -15,8 +15,7 @@ import com.genersoft.iot.vmp.service.IInviteStreamService;
import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
@@ -30,12 +29,11 @@ import java.text.ParseException;
*/
@SuppressWarnings(value = {"rawtypes", "unchecked"})
@Slf4j
@RestController
@RequestMapping(value = "/api/v1/stream")
public class ApiStreamController {
private final static Logger logger = LoggerFactory.getLogger(ApiStreamController.class);
@Autowired
private SIPCommander cmder;
@@ -93,7 +91,7 @@ public class ApiStreamController {
return result;
}
result.onTimeout(()->{
logger.info("播放等待超时");
log.info("播放等待超时");
JSONObject resultJSON = new JSONObject();
resultJSON.put("error","timeout");
result.setResult(resultJSON);