MCPcopy
hub / github.com/nukeop/nuclear / createLogEntry

Function createLogEntry

packages/player/src/hooks/useLogStream.ts:41–72  ·  view source on GitHub ↗
(
  message: string,
  level: LogLevel,
  timestamp: Date,
)

Source from the content-addressed store, hash-verified

39};
40
41const createLogEntry = (
42 message: string,
43 level: LogLevel,
44 timestamp: Date,
45): LogEntry => {
46 const formatMatch = message.match(LOG_FORMAT_REGEX);
47
48 let target = '';
49 let remainder = message;
50
51 if (formatMatch) {
52 target = formatMatch[1];
53 remainder = formatMatch[2];
54 }
55
56 const scopeMatch = remainder.match(SCOPE_PREFIX_REGEX);
57 const scopeRaw = scopeMatch?.[1] ?? '';
58 const content = scopeMatch?.[2] ?? remainder;
59 const isPlugin = scopeRaw.startsWith('plugin:');
60
61 return {
62 id: uuid(),
63 timestamp,
64 level,
65 target,
66 source: {
67 type: isPlugin ? 'plugin' : 'core',
68 scope: isPlugin ? scopeRaw.slice(7) : scopeRaw,
69 },
70 message: content,
71 };
72};
73
74const logBuffer = new RingBuffer<LogEntry>(MAX_LOG_ENTRIES);
75let logStreamInitialized = false;

Callers 1

initLogStreamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected