Build an instance of a logging function for the provided level.
( loadCommand: () => Function, level: LogLevel, defaultColor: ((text: string) => string) | null, )
| 58 | } |
| 59 | |
| 60 | /** Build an instance of a logging function for the provided level. */ |
| 61 | function buildLogLevelFunction( |
| 62 | loadCommand: () => Function, |
| 63 | level: LogLevel, |
| 64 | defaultColor: ((text: string) => string) | null, |
| 65 | ) { |
| 66 | /** Write to stdout for the LOG_LEVEL. */ |
| 67 | return (...values: unknown[]) => { |
| 68 | runConsoleCommand( |
| 69 | loadCommand, |
| 70 | level, |
| 71 | // For string values, apply the default color. |
| 72 | ...values.map((v) => (typeof v === 'string' && defaultColor ? defaultColor(v) : v)), |
| 73 | ); |
| 74 | }; |
| 75 | } |
| 76 | |
| 77 | /** |
no test coverage detected