mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-29 07:56:37 +08:00
增加日志输出
This commit is contained in:
Binary file not shown.
@@ -346,20 +346,15 @@ func ParseService(cfg *config.ServiceConfig) (service.Service, error) {
|
||||
handlerLogger.Error("init: ", err)
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println("开始注册观察器")
|
||||
var observer observer.Observer
|
||||
// 如果服务名以_tls结尾,则不启用观察器
|
||||
if strings.HasSuffix(cfg.Name, "_tls") {
|
||||
observer = nil
|
||||
fmt.Println("服务名以_tls结尾,跳过观察器启用")
|
||||
} else if cfg.Observer != "" {
|
||||
fmt.Println("def")
|
||||
observer = registry.ObserverRegistry().Get(cfg.Observer)
|
||||
} else if pStats != nil {
|
||||
fmt.Println("console")
|
||||
observer = registry.ObserverRegistry().Get("console")
|
||||
} else {
|
||||
fmt.Println("err")
|
||||
}
|
||||
|
||||
s := xservice.NewService(cfg.Name, ln, h,
|
||||
|
||||
@@ -353,7 +353,6 @@ func (s *defaultService) observeStats(ctx context.Context) {
|
||||
}
|
||||
|
||||
isUpdated := st.IsUpdated()
|
||||
fmt.Println("isUpdated", isUpdated)
|
||||
if isUpdated {
|
||||
inputBytes := st.Get(stats.KindInputBytes)
|
||||
outputBytes := st.Get(stats.KindOutputBytes)
|
||||
|
||||
@@ -143,25 +143,19 @@ public class FlowController extends BaseController {
|
||||
return SUCCESS_RESPONSE;
|
||||
}
|
||||
|
||||
try {
|
||||
// 2. 尝试解密数据
|
||||
String decryptedData = decryptIfNeeded(rawData, secret);
|
||||
// 2. 尝试解密数据
|
||||
String decryptedData = decryptIfNeeded(rawData, secret);
|
||||
|
||||
// 3. 解析为FlowDto列表
|
||||
FlowDto flowDataList = JSONObject.parseObject(decryptedData, FlowDto.class);
|
||||
if (Objects.equals(flowDataList.getN(), "web_api")) {
|
||||
return SUCCESS_RESPONSE;
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
log.info("节点上报流量数据{}", flowDataList);
|
||||
// 4. 处理流量数据
|
||||
return processFlowData(flowDataList);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理流量数据失败: {}", e.getMessage(), e);
|
||||
// 3. 解析为FlowDto列表
|
||||
FlowDto flowDataList = JSONObject.parseObject(decryptedData, FlowDto.class);
|
||||
if (Objects.equals(flowDataList.getN(), "web_api")) {
|
||||
return SUCCESS_RESPONSE;
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
log.info("节点上报流量数据{}", flowDataList);
|
||||
// 4. 处理流量数据
|
||||
return processFlowData(flowDataList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -788,32 +788,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
return getCurrentHour();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成24小时全0数据(异常情况使用)
|
||||
*/
|
||||
private List<StatisticsFlow> generateEmpty24HourData(Long userId) {
|
||||
List<StatisticsFlow> result = new ArrayList<>();
|
||||
int currentHour = getCurrentHour();
|
||||
|
||||
for (int i = 0; i < 24; i++) {
|
||||
StatisticsFlow emptyFlow = new StatisticsFlow();
|
||||
emptyFlow.setUserId(userId);
|
||||
emptyFlow.setFlow(0L);
|
||||
emptyFlow.setTotalFlow(0L);
|
||||
emptyFlow.setTime(String.format("%02d:00", currentHour));
|
||||
result.add(emptyFlow);
|
||||
|
||||
currentHour--;
|
||||
if (currentHour < 0) currentHour = 23;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ========== 内部数据类 ==========
|
||||
|
||||
|
||||
Reference in New Issue
Block a user