[*] 添加日志
This commit is contained in:
@@ -35,6 +35,13 @@ public class RoomController {
|
||||
this.roomManager = roomManager;
|
||||
}
|
||||
|
||||
@Operation(summary = "房间信息", description = "房间信息")
|
||||
@GetMapping("/log")
|
||||
public Message log() {
|
||||
this.roomManager.log();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "房间列表", description = "房间列表")
|
||||
@GetMapping("/list")
|
||||
@ApiResponse(content = @Content(schema = @Schema(implementation = RoomStatus.class)))
|
||||
|
||||
@@ -8,12 +8,14 @@ import com.acgist.taoyao.signal.client.Client;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 终端包装器:Peer
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
public class ClientWrapper implements AutoCloseable {
|
||||
@@ -109,7 +111,7 @@ public class ClientWrapper implements AutoCloseable {
|
||||
/**
|
||||
* 数据通道消费者
|
||||
*/
|
||||
private final Map<String, DataProducer> dataConsumers;
|
||||
private final Map<String, DataConsumer> dataConsumers;
|
||||
|
||||
public ClientWrapper(Room room, Client client) {
|
||||
this.room = room;
|
||||
@@ -158,5 +160,27 @@ public class ClientWrapper implements AutoCloseable {
|
||||
this.recvTransport.close();
|
||||
this.sendTransport.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
*/
|
||||
public void log() {
|
||||
log.debug("""
|
||||
当前终端:{}
|
||||
消费者数量:{}
|
||||
生产者数量:{}
|
||||
数据消费者数量:{}
|
||||
数据生产者数量:{}""",
|
||||
this.clientId,
|
||||
this.consumers.size(),
|
||||
this.producers.size(),
|
||||
this.dataConsumers.size(),
|
||||
this.dataProducers.size()
|
||||
);
|
||||
this.consumers.values().forEach(Consumer::log);
|
||||
this.producers.values().forEach(Producer::log);
|
||||
this.dataConsumers.values().forEach(DataConsumer::log);
|
||||
this.dataProducers.values().forEach(DataProducer::log);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,4 +69,11 @@ public class Consumer implements Closeable {
|
||||
EventPublisher.publishEvent(new MediaConsumerCloseEvent(this.consumerId, this.room));
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
*/
|
||||
public void log() {
|
||||
log.debug("当前消费者:{} - {} - {}", this.consumerId, this.kind, this.streamId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package com.acgist.taoyao.signal.party.media;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 数据消费者
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
public class DataConsumer {
|
||||
@@ -36,4 +38,11 @@ public class DataConsumer {
|
||||
this.consumerId = consumerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
*/
|
||||
public void log() {
|
||||
log.debug("当前数据消费者:{} - {}", this.consumerId, this.streamId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,12 +5,14 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 数据生产者
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Slf4j
|
||||
@Setter
|
||||
@Getter
|
||||
public class DataProducer {
|
||||
@@ -39,4 +41,12 @@ public class DataProducer {
|
||||
this.dataConsumers = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
*/
|
||||
public void log() {
|
||||
log.debug("当前数据生产者:{} - {}", this.producerId, this.streamId);
|
||||
this.dataConsumers.values().forEach(DataConsumer::log);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,4 +81,12 @@ public class Producer implements Closeable {
|
||||
EventPublisher.publishEvent(new MediaProducerCloseEvent(this.producerId, this.room));
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
*/
|
||||
public void log() {
|
||||
log.debug("当前生产者:{} - {} - {}", this.producerId, this.kind, this.streamId);
|
||||
this.consumers.values().forEach(Consumer::log);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -239,5 +239,18 @@ public class Room implements Closeable {
|
||||
// TODO:媒体服务:直接没提服务关闭所有资源(通道、生产者、消费者)
|
||||
this.roomManager.remove(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
*/
|
||||
public void log() {
|
||||
log.info("""
|
||||
当前房间:{}
|
||||
终端数量:{}""",
|
||||
this.roomId,
|
||||
this.clients.size()
|
||||
);
|
||||
this.clients.values().forEach(ClientWrapper::log);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ public class RoomManager {
|
||||
this.rooms = new CopyOnWriteArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param roomId 房间标识
|
||||
*
|
||||
@@ -152,4 +151,15 @@ public class RoomManager {
|
||||
this.rooms.remove(room);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
*/
|
||||
public void log() {
|
||||
log.info("""
|
||||
当前房间数量:{}""",
|
||||
this.rooms.size()
|
||||
);
|
||||
this.rooms.forEach(Room::log);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user