Function
formatLog
(level: LogLevel, message: string, data?: unknown)
Source from the content-addressed store, hash-verified
| 13 | } |
| 14 | |
| 15 | function formatLog(level: LogLevel, message: string, data?: unknown): LogData { |
| 16 | const logData: LogData = { |
| 17 | level, |
| 18 | message, |
| 19 | timestamp: new Date().toISOString(), |
| 20 | }; |
| 21 | |
| 22 | if (data instanceof Error) { |
| 23 | logData.error = { |
| 24 | message: data.message, |
| 25 | stack: data.stack, |
| 26 | cause: data.cause, |
| 27 | }; |
| 28 | } else if (data !== undefined) { |
| 29 | logData.data = data; |
| 30 | } |
| 31 | |
| 32 | return logData; |
| 33 | } |
| 34 | |
| 35 | export const logger = { |
| 36 | info: (message: string, data?: unknown) => { |
Tested by
no test coverage detected