chore: 提交调试文档与模拟器改动
This commit is contained in:
@@ -14,12 +14,18 @@ export interface MockSimulatorDebugLoggerState {
|
||||
export interface MockSimulatorDebugLogEntry {
|
||||
type: 'debug-log'
|
||||
timestamp: number
|
||||
channelId?: string
|
||||
scope: string
|
||||
level: MockSimulatorDebugLogLevel
|
||||
message: string
|
||||
payload?: Record<string, unknown>
|
||||
}
|
||||
|
||||
function normalizeMockSimulatorChannelId(rawChannelId: string | null | undefined): string {
|
||||
const trimmed = String(rawChannelId || '').trim()
|
||||
return trimmed || 'default'
|
||||
}
|
||||
|
||||
function normalizeMockSimulatorLogUrl(rawUrl: string): string {
|
||||
const trimmed = String(rawUrl || '').trim()
|
||||
if (!trimmed) {
|
||||
@@ -45,6 +51,7 @@ export class MockSimulatorDebugLogger {
|
||||
connected: boolean
|
||||
connecting: boolean
|
||||
url: string
|
||||
channelId: string
|
||||
queue: MockSimulatorDebugLogEntry[]
|
||||
onStateChange?: (state: MockSimulatorDebugLoggerState) => void
|
||||
|
||||
@@ -54,6 +61,7 @@ export class MockSimulatorDebugLogger {
|
||||
this.connected = false
|
||||
this.connecting = false
|
||||
this.url = DEFAULT_DEBUG_LOG_URL
|
||||
this.channelId = 'default'
|
||||
this.queue = []
|
||||
this.onStateChange = onStateChange
|
||||
}
|
||||
@@ -114,6 +122,10 @@ export class MockSimulatorDebugLogger {
|
||||
this.connect()
|
||||
}
|
||||
|
||||
setChannelId(channelId: string): void {
|
||||
this.channelId = normalizeMockSimulatorChannelId(channelId)
|
||||
}
|
||||
|
||||
log(
|
||||
scope: string,
|
||||
level: MockSimulatorDebugLogLevel,
|
||||
@@ -127,6 +139,7 @@ export class MockSimulatorDebugLogger {
|
||||
const entry: MockSimulatorDebugLogEntry = {
|
||||
type: 'debug-log',
|
||||
timestamp: Date.now(),
|
||||
channelId: this.channelId,
|
||||
scope,
|
||||
level,
|
||||
message,
|
||||
@@ -185,11 +198,13 @@ export class MockSimulatorDebugLogger {
|
||||
this.send({
|
||||
type: 'debug-log',
|
||||
timestamp: Date.now(),
|
||||
channelId: this.channelId,
|
||||
scope: 'logger',
|
||||
level: 'info',
|
||||
message: 'logger channel connected',
|
||||
payload: {
|
||||
url: this.url,
|
||||
channelId: this.channelId,
|
||||
},
|
||||
})
|
||||
this.flush()
|
||||
|
||||
Reference in New Issue
Block a user