初步实现前端展示

This commit is contained in:
648540858
2024-11-01 14:51:11 +08:00
parent db531ecde1
commit 71c0de2aa9
5 changed files with 20 additions and 10 deletions

View File

@@ -3,10 +3,11 @@ package com.genersoft.iot.vmp.conf.webLog;
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import com.genersoft.iot.vmp.utils.DateUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.nio.charset.StandardCharsets;
@Data
@EqualsAndHashCode(callSuper = true)
public class WebSocketAppender extends AppenderBase<ILoggingEvent> {
@@ -17,6 +18,7 @@ public class WebSocketAppender extends AppenderBase<ILoggingEvent> {
protected void append(ILoggingEvent loggingEvent) {
byte[] data = this.encoder.encode(loggingEvent);
// Push to client.
LogChannel.push(DateUtil.timestampMsTo_yyyy_MM_dd_HH_mm_ss(loggingEvent.getTimeStamp()) + " " + loggingEvent.getFormattedMessage());
// LogChannel.push(DateUtil.timestampMsTo_yyyy_MM_dd_HH_mm_ss(loggingEvent.getTimeStamp()) + " " + loggingEvent.getFormattedMessage());
LogChannel.push(new String(data, StandardCharsets.UTF_8));
}
}