MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / emitAt

Method emitAt

packages/agent-core/src/logging/logger.ts:299–324  ·  view source on GitHub ↗
(
    level: Exclude<LogLevel, 'off'>,
    message: string,
    payload: LogPayload,
  )

Source from the content-addressed store, hash-verified

297 }
298
299 private emitAt(
300 level: Exclude<LogLevel, 'off'>,
301 message: string,
302 payload: LogPayload,
303 ): void {
304 const root = getRootInternal();
305 if (!root.isConfigured()) return;
306 try {
307 const { ctx: payloadCtx, error } = resolvePayload(payload);
308 // Bound ctx wins so call-site can't overwrite ownership fields.
309 const ctx = mergeCtx(payloadCtx, this.boundCtx);
310 const sessionId = ctx?.['sessionId'];
311 const sessionLogId = (ctx as InternalLogContext | undefined)?.[SESSION_LOG_ID];
312 root.emit({
313 t: Date.now(),
314 level,
315 msg: message,
316 ctx: stripInternalCtx(ctx),
317 error,
318 sessionId: typeof sessionId === 'string' ? sessionId : undefined,
319 sessionLogId: typeof sessionLogId === 'string' ? sessionLogId : undefined,
320 });
321 } catch {
322 // Diagnostic logging is best-effort and must never affect main control flow.
323 }
324 }
325}
326
327type InternalLogContext = LogContext & { [SESSION_LOG_ID]?: unknown };

Callers 4

errorMethod · 0.95
warnMethod · 0.95
infoMethod · 0.95
debugMethod · 0.95

Calls 7

getRootInternalFunction · 0.85
resolvePayloadFunction · 0.85
mergeCtxFunction · 0.85
stripInternalCtxFunction · 0.85
isConfiguredMethod · 0.65
nowMethod · 0.65
emitMethod · 0.45

Tested by

no test coverage detected