mirror of https://github.com/swwheihei/wvp.git
修改 gb28181日志 log.debug
parent
2246ffa187
commit
518b751525
|
@ -21,3 +21,4 @@
|
|||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/.idea
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.genersoft.iot.vmp;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class Swagger2 {
|
||||
|
||||
/**
|
||||
* 创建API应用
|
||||
* apiInfo() 增加API相关信息
|
||||
* 通过select()函数返回一个ApiSelectorBuilder实例,用来控制哪些接口暴露给Swagger来展现,
|
||||
* 本例采用指定扫描的包路径来定义指定要建立API的目录。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.genersoft.iot.vmp"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建该API的基本信息(这些基本信息会展现在文档页面中)
|
||||
* 访问地址:http://项目实际地址/swagger-ui.html
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("GB28181接口文档")
|
||||
.description("")
|
||||
.termsOfServiceUrl("")
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package com.genersoft.iot.vmp.gb28181.event.offline;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
||||
|
@ -16,7 +18,7 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
|||
*/
|
||||
@Component
|
||||
public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(KeepliveTimeoutListener.class);
|
||||
@Autowired
|
||||
private EventPublisher publisher;
|
||||
|
||||
|
@ -34,7 +36,7 @@ public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener {
|
|||
// 获取失效的key
|
||||
String expiredKey = message.toString();
|
||||
if(!expiredKey.startsWith(VideoManagerConstants.KEEPLIVEKEY_PREFIX)){
|
||||
System.out.println("收到redis过期监听,但开头不是"+VideoManagerConstants.KEEPLIVEKEY_PREFIX+",忽略");
|
||||
log.debug("收到redis过期监听,但开头不是"+VideoManagerConstants.KEEPLIVEKEY_PREFIX+",忽略");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import javax.sip.ClientTransaction;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
|
@ -14,6 +16,7 @@ import org.springframework.stereotype.Component;
|
|||
*/
|
||||
@Component
|
||||
public class VideoStreamSessionManager {
|
||||
private static Logger log = LoggerFactory.getLogger(VideoStreamSessionManager.class);
|
||||
|
||||
private ConcurrentHashMap<String, ClientTransaction> sessionMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
@ -48,7 +51,7 @@ public class VideoStreamSessionManager {
|
|||
while (true == col.contains(ssrc)) {
|
||||
col.remove(ssrc);
|
||||
}
|
||||
System.out.println(deviceSessionMap);
|
||||
log.debug(deviceSessionMap.toString());
|
||||
}
|
||||
|
||||
public void putDevice(String deviceAndChannel,String ssrc){
|
||||
|
|
|
@ -9,6 +9,8 @@ import javax.sip.message.Request;
|
|||
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
|
||||
|
||||
import gov.nist.javax.sip.header.CSeq;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @Description:ACK请求处理器
|
||||
|
@ -16,7 +18,7 @@ import gov.nist.javax.sip.header.CSeq;
|
|||
* @date: 2020年5月3日 下午5:31:45
|
||||
*/
|
||||
public class AckRequestProcessor extends SIPRequestAbstractProcessor {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(AckRequestProcessor.class);
|
||||
/**
|
||||
* 处理 ACK请求
|
||||
*
|
||||
|
@ -34,7 +36,7 @@ public class AckRequestProcessor extends SIPRequestAbstractProcessor {
|
|||
CSeq csReq = (CSeq) request.getHeader(CSeq.NAME);
|
||||
ackRequest = dialog.createAck(csReq.getSeqNumber());
|
||||
dialog.sendAck(ackRequest);
|
||||
System.out.println("send ack to callee:" + ackRequest.toString());
|
||||
log.debug("send ack to callee:" + ackRequest.toString());
|
||||
} catch (SipException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidArgumentException e) {
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.transmit.request.impl;
|
|||
import javax.sip.RequestEvent;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @Description:处理INVITE请求
|
||||
|
@ -10,7 +12,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcesso
|
|||
* @date: 2020年5月3日 下午4:43:52
|
||||
*/
|
||||
public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(InviteRequestProcessor.class);
|
||||
/**
|
||||
* 处理invite请求
|
||||
*
|
||||
|
@ -29,7 +31,7 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
|||
// URI reqUri = request.getRequestURI();
|
||||
// URI contactURI = currUser.get(reqUri);
|
||||
//
|
||||
// System.out.println("processInvite rqStr=" + reqUri + " contact=" + contactURI);
|
||||
// log.debug("processInvite rqStr=" + reqUri + " contact=" + contactURI);
|
||||
//
|
||||
// // 根据Request uri来路由,后续的响应消息通过VIA来路由
|
||||
// Request cliReq = messageFactory.createRequest(request.toString());
|
||||
|
@ -54,9 +56,9 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
|||
// clientTransactionId = sipProvider.getNewClientTransaction(cliReq);
|
||||
// clientTransactionId.sendRequest();
|
||||
//
|
||||
// System.out.println("processInvite clientTransactionId=" + clientTransactionId.toString());
|
||||
// log.debug("processInvite clientTransactionId=" + clientTransactionId.toString());
|
||||
//
|
||||
// System.out.println("send invite to callee: " + cliReq);
|
||||
// log.debug("send invite to callee: " + cliReq);
|
||||
// } catch (TransactionUnavailableException e1) {
|
||||
// e1.printStackTrace();
|
||||
// } catch (SipException e) {
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.transmit.request.impl;
|
|||
import javax.sip.RequestEvent;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @Description:暂不支持的消息请求处理器
|
||||
|
@ -10,7 +12,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcesso
|
|||
* @date: 2020年5月3日 下午5:32:59
|
||||
*/
|
||||
public class OtherRequestProcessor extends SIPRequestAbstractProcessor {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(OtherRequestProcessor.class);
|
||||
/**
|
||||
* <p>Title: process</p>
|
||||
* <p>Description: </p>
|
||||
|
@ -21,7 +23,7 @@ public class OtherRequestProcessor extends SIPRequestAbstractProcessor {
|
|||
*/
|
||||
@Override
|
||||
public void process(RequestEvent evt) {
|
||||
System.out.println("no support the method! Method:" + evt.getRequest().getMethod());
|
||||
log.debug("no support the method! Method:" + evt.getRequest().getMethod());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ import javax.sip.header.ViaHeader;
|
|||
import javax.sip.message.Request;
|
||||
import javax.sip.message.Response;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||
|
@ -38,6 +40,7 @@ import gov.nist.javax.sip.header.Expires;
|
|||
* @date: 2020年5月3日 下午4:47:25
|
||||
*/
|
||||
public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
|
||||
private static Logger log = LoggerFactory.getLogger(RegisterRequestProcessor.class);
|
||||
|
||||
private SipConfig sipConfig;
|
||||
|
||||
|
@ -56,9 +59,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
|
|||
@Override
|
||||
public void process(RequestEvent evt) {
|
||||
try {
|
||||
System.out.println("收到注册请求,开始处理");
|
||||
log.debug("收到注册请求,开始处理");
|
||||
Request request = evt.getRequest();
|
||||
|
||||
log.debug("request: {}",request.toString());
|
||||
Response response = null;
|
||||
boolean passwordCorrect = false;
|
||||
// 注册标志 0:未携带授权头或者密码错误 1:注册成功 2:注销成功
|
||||
|
@ -75,9 +78,9 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
|
|||
if (authorhead == null || !passwordCorrect) {
|
||||
|
||||
if (authorhead == null) {
|
||||
System.out.println("未携带授权头 回复401");
|
||||
log.debug("未携带授权头 回复401");
|
||||
} else if (!passwordCorrect) {
|
||||
System.out.println("密码错误 回复401");
|
||||
log.debug("密码错误 回复401");
|
||||
}
|
||||
response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request);
|
||||
new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getSipDomain());
|
||||
|
@ -137,12 +140,12 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
|
|||
// 保存到redis
|
||||
// 下发catelog查询目录
|
||||
if (registerFlag == 1 && device != null) {
|
||||
System.out.println("注册成功! deviceId:" + device.getDeviceId());
|
||||
log.debug("注册成功! deviceId:" + device.getDeviceId());
|
||||
storager.update(device);
|
||||
publisher.onlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_ONLINE_REGISTER);
|
||||
handler.onRegister(device);
|
||||
} else if (registerFlag == 2) {
|
||||
System.out.println("注销成功! deviceId:" + device.getDeviceId());
|
||||
log.debug("注销成功! deviceId:" + device.getDeviceId());
|
||||
publisher.outlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_OUTLINE_UNREGISTER);
|
||||
}
|
||||
} catch (SipException | InvalidArgumentException | NoSuchAlgorithmException | ParseException e) {
|
||||
|
|
|
@ -11,6 +11,8 @@ import javax.sip.message.Request;
|
|||
import javax.sip.message.Response;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @Description:SUBSCRIBE请求处理器
|
||||
|
@ -18,7 +20,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcesso
|
|||
* @date: 2020年5月3日 下午5:31:20
|
||||
*/
|
||||
public class SubscribeRequestProcessor extends SIPRequestAbstractProcessor {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(SubscribeRequestProcessor.class);
|
||||
/**
|
||||
* 处理SUBSCRIBE请求
|
||||
*
|
||||
|
@ -38,13 +40,13 @@ public class SubscribeRequestProcessor extends SIPRequestAbstractProcessor {
|
|||
ExpiresHeader expireHeader = getHeaderFactory().createExpiresHeader(30);
|
||||
response.setExpires(expireHeader);
|
||||
}
|
||||
System.out.println("response : " + response.toString());
|
||||
log.debug("response : " + response.toString());
|
||||
ServerTransaction transaction = getServerTransaction(evt);
|
||||
if (transaction != null) {
|
||||
transaction.sendResponse(response);
|
||||
transaction.terminate();
|
||||
} else {
|
||||
System.out.println("processRequest serverTransactionId is null.");
|
||||
log.debug("processRequest serverTransactionId is null.");
|
||||
}
|
||||
|
||||
} catch (ParseException e) {
|
||||
|
|
|
@ -39,4 +39,7 @@ sip:
|
|||
media:
|
||||
# ip: 10.200.64.88
|
||||
ip: 192.168.0.102
|
||||
port: 10000
|
||||
port: 10000
|
||||
|
||||
log:
|
||||
path: /app/lboss/pro/gb28181/logs
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<configuration>
|
||||
<!-- 变量 -->
|
||||
<!--定义日志保存的路径-->
|
||||
<!--1.更改默认的logback.xml为logback-spring.xml
|
||||
SpringBoot当看到logback-spring.xml文件存在的时候,才会启动日志的环境切换
|
||||
logback.xml文件没法做到
|
||||
2. 在需要切换的环境上增加springProfile标签
|
||||
-->
|
||||
|
||||
<springProperty scope="context" name="logPath" source="log.path" defaultValue="/" />
|
||||
|
||||
<property name="LOG_HOME" value="${logPath}" />
|
||||
<!-- <springProfile name="dev">
|
||||
</springProfile>
|
||||
<springProfile name="pro">
|
||||
<property name="LOG_HOME" value="/app/lboss/logs" />
|
||||
</springProfile>
|
||||
<springProfile name="test">
|
||||
<property name="LOG_HOME" value="/app/lboss/logs" />
|
||||
</springProfile> -->
|
||||
<!-- 日志文件保存路径 -->
|
||||
<property name="filePath" value="${LOG_HOME}/gb28181.%d{yyyy-MM-dd}.log" />
|
||||
<!-- 日志打印规则 -->
|
||||
<property name="consolePattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%21thread] [%3line] %5level gb28181[0]: %50logger{5} - %msg%n" />
|
||||
|
||||
<!-- 控制台输出日志 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${consolePattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- 输出到文件 -->
|
||||
<appender name="DayFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${filePath}</fileNamePattern>
|
||||
<maxHistory>30</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${consolePattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="DayFile" />
|
||||
</root>
|
||||
<logger name="com.vizhuo">
|
||||
<level value="DEBUG" />
|
||||
</logger>
|
||||
</configuration>
|
Loading…
Reference in New Issue