MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / record

Method record

graph-ui/src/app/ui-log.ts:206–251  ·  view source on GitHub ↗

Queue one entry. Never throws and never writes to the console.

(level: UiLogLevel, source: string, message: string, extra: UiLogExtra = {})

Source from the content-addressed store, hash-verified

204
205 /** Queue one entry. Never throws and never writes to the console. */
206 record(level: UiLogLevel, source: string, message: string, extra: UiLogExtra = {}): void {
207 const entry: UiLogEntry = {
208 ts: this.now().toISOString(),
209 seq: ++this.seq,
210 level,
211 source: source.slice(0, 64),
212 message: capField(message),
213 };
214 const project = extra.project ?? this.options.getProject?.();
215 if (project !== undefined) {
216 entry.project = project;
217 }
218 if (extra.detail !== undefined && extra.detail.length > 0) {
219 entry.detail = capField(extra.detail);
220 }
221 if (extra.stack !== undefined && extra.stack.length > 0) {
222 entry.stack = capField(extra.stack);
223 }
224 if (extra.url !== undefined && extra.url.length > 0) {
225 entry.url = capField(extra.url, 1024);
226 }
227 if (typeof extra.line === 'number' && Number.isFinite(extra.line)) {
228 entry.line = extra.line;
229 }
230 if (typeof extra.col === 'number' && Number.isFinite(extra.col)) {
231 entry.col = extra.col;
232 }
233 // Only a truly identical entry is counted: the same text from another place stays its own entry.
234 const key = JSON.stringify([entry.level, entry.source, entry.project ?? '', entry.message, entry.detail ?? '',
235 entry.stack ?? '', entry.url ?? '', entry.line ?? null, entry.col ?? null]);
236 const repeat = this.repeats.get(key);
237 if (repeat !== undefined) {
238 this.seq -= 1;
239 repeat.count += 1;
240 if (powerOfTen(repeat.count)) {
241 this.report(repeat);
242 this.arm(this.flushMs);
243 }
244 return;
245 }
246 if (this.repeats.size < UI_LOG_REPEAT_KEYS_MAX) {
247 this.repeats.set(key, { entry, count: 1, reported: 1 });
248 }
249 this.push(entry);
250 this.arm(this.flushMs);
251 }
252
253 /** Queue the running count of a repeated entry, with every field of its first occurrence. */
254 private report(repeat: Repeat): void {

Callers 5

ui-log.test.tsFile · 0.45
installUiLogFunction · 0.45
onErrorFunction · 0.45
onRejectionFunction · 0.45

Calls 6

reportMethod · 0.95
armMethod · 0.95
pushMethod · 0.95
capFieldFunction · 0.85
powerOfTenFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected