MCPcopy Create free account
hub / github.com/anus-dev/ANUS / logMessage

Method logMessage

packages/core/src/core/logger.ts:241–269  ·  view source on GitHub ↗
(type: MessageSenderType, message: string)

Source from the content-addressed store, hash-verified

239 }
240
241 async logMessage(type: MessageSenderType, message: string): Promise<void> {
242 if (!this.initialized || this.sessionId === undefined) {
243 console.debug(
244 'Logger not initialized or session ID missing. Cannot log message.',
245 );
246 return;
247 }
248
249 // The messageId used here is the instance's idea of the next ID.
250 // _updateLogFile will verify and potentially recalculate based on the file's actual state.
251 const newEntryObject: LogEntry = {
252 sessionId: this.sessionId,
253 messageId: this.messageId, // This will be recalculated in _updateLogFile
254 type,
255 message,
256 timestamp: new Date().toISOString(),
257 };
258
259 try {
260 const writtenEntry = await this._updateLogFile(newEntryObject);
261 if (writtenEntry) {
262 // If an entry was actually written (not a duplicate skip),
263 // then this instance can increment its idea of the next messageId for this session.
264 this.messageId = writtenEntry.messageId + 1;
265 }
266 } catch (_error) {
267 // Error already logged by _updateLogFile or _readLogFile
268 }
269 }
270
271 private _checkpointPath(tag: string): string {
272 if (!tag.length) {

Callers 2

logger.test.tsFile · 0.80
useAnusStreamFunction · 0.80

Calls 2

_updateLogFileMethod · 0.95
debugMethod · 0.80

Tested by

no test coverage detected