(prefixFactory: (level: LogLevel) => string)
| 1811 | const logError = logEffect("error"); |
| 1812 | |
| 1813 | function withPrefix(prefixFactory: (level: LogLevel) => string) { |
| 1814 | return defineHandlerFor<Logging>().with((self) => |
| 1815 | self.handle( |
| 1816 | (name): name is Logging["name"] => typeof name === "string" && name.startsWith("logging."), |
| 1817 | function* ({ effect, resume }): Generator<Logging, void> { |
| 1818 | const prefix = prefixFactory(effect.name.slice("logging.".length) as LogLevel); |
| 1819 | effect.payloads.splice(0, 0, prefix); |
| 1820 | yield effect; |
| 1821 | resume(); |
| 1822 | }, |
| 1823 | ), |
| 1824 | ); |
| 1825 | } |
| 1826 | |
| 1827 | function withMinimumLogLevel(level: LogLevel | "none") { |
| 1828 | return defineHandlerFor<Logging>().with((self) => { |
no test coverage detected