(options: TaskNotesLoggerOptions = {})
| 78 | } |
| 79 | |
| 80 | export function createTaskNotesLogger(options: TaskNotesLoggerOptions = {}): TaskNotesLogger { |
| 81 | const sink = options.sink ?? console; |
| 82 | const isDebugEnabled = options.isDebugEnabled ?? (() => false); |
| 83 | |
| 84 | return { |
| 85 | debug(message, metadata) { |
| 86 | if (!isDebugEnabled()) { |
| 87 | return; |
| 88 | } |
| 89 | emitLog(sink, "debug", options.tag, message, metadata); |
| 90 | }, |
| 91 | info(message, metadata) { |
| 92 | emitLog(sink, "info", options.tag, message, metadata); |
| 93 | }, |
| 94 | warn(message, metadata) { |
| 95 | emitLog(sink, "warn", options.tag, message, metadata); |
| 96 | }, |
| 97 | error(message, metadata) { |
| 98 | emitLog(sink, "error", options.tag, message, metadata); |
| 99 | }, |
| 100 | child(tag) { |
| 101 | const parentTag = options.tag; |
| 102 | return createTaskNotesLogger({ |
| 103 | ...options, |
| 104 | tag: () => { |
| 105 | const parent = getTagValue(parentTag); |
| 106 | const child = getTagValue(tag); |
| 107 | return [parent, child].filter(Boolean).join("/"); |
| 108 | }, |
| 109 | }); |
| 110 | }, |
| 111 | }; |
| 112 | } |
| 113 | |
| 114 | export function getUserSafeErrorMessage( |
| 115 | category: TaskNotesLogCategory, |
no outgoing calls
no test coverage detected