* Add a new log entry
(
level: LogLevel,
source: string,
message: string,
details?: any
)
| 42 | * Add a new log entry |
| 43 | */ |
| 44 | public log( |
| 45 | level: LogLevel, |
| 46 | source: string, |
| 47 | message: string, |
| 48 | details?: any |
| 49 | ): LogEntry { |
| 50 | const entry: LogEntry = { |
| 51 | id: `log-${this.nextLogId++}`, |
| 52 | timestamp: new Date(), |
| 53 | level, |
| 54 | source, |
| 55 | message, |
| 56 | details |
| 57 | }; |
| 58 | |
| 59 | // Add to log array |
| 60 | this.logs.push(entry); |
| 61 | |
| 62 | // Trim logs if we exceed max size |
| 63 | if (this.logs.length > this.maxLogEntries) { |
| 64 | this.logs = this.logs.slice(-this.maxLogEntries); |
| 65 | } |
| 66 | |
| 67 | // Notify all listeners |
| 68 | this.notifyListeners(entry); |
| 69 | |
| 70 | return entry; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Convenience method for debug logs |
no test coverage detected