Feat : Log recorder
This commit is contained in:
@@ -2,6 +2,7 @@ import { randomUUID } from 'node:crypto';
|
||||
import type { WebSocket } from 'ws';
|
||||
import type {
|
||||
AgentAction,
|
||||
AgentEvent,
|
||||
AgentStatus,
|
||||
AgentView,
|
||||
LogEntry,
|
||||
@@ -234,8 +235,14 @@ class Hub {
|
||||
}
|
||||
|
||||
/** Journalise un évènement : persistance + diffusion temps réel. */
|
||||
log(agentId: string | null, level: LogLevel, message: string, ts = Date.now()): LogEntry {
|
||||
const entry = logsRepo.append(agentId, level, message, ts);
|
||||
log(
|
||||
agentId: string | null,
|
||||
level: LogLevel,
|
||||
message: string,
|
||||
ts = Date.now(),
|
||||
event: AgentEvent | null = null,
|
||||
): LogEntry {
|
||||
const entry = logsRepo.append(agentId, level, message, ts, event);
|
||||
this.broadcast({ type: 'log', entry });
|
||||
if (level === 'error' || level === 'warn') {
|
||||
console.warn(`[${level}] ${entry.agentName ?? 'serveur'} — ${message}`);
|
||||
|
||||
Reference in New Issue
Block a user