(prefixFactory: (level: LogLevel) => string)
| 1145 | const logError = logEffect("error"); |
| 1146 | |
| 1147 | function withPrefix(prefixFactory: (level: LogLevel) => string) { |
| 1148 | return defineHandlerFor<Logging>().with((self) => |
| 1149 | self.handle( |
| 1150 | (name): name is Logging["name"] => typeof name === "string" && name.startsWith("logging."), |
| 1151 | function* ({ effect, resume }): Generator<Logging, void> { |
| 1152 | const prefix = prefixFactory(effect.name.slice("logging.".length) as LogLevel); |
| 1153 | effect.payloads.splice(0, 0, prefix); |
| 1154 | yield effect; |
| 1155 | resume(); |
| 1156 | }, |
| 1157 | ), |
| 1158 | ); |
| 1159 | } |
| 1160 | |
| 1161 | function withMinimumLogLevel(level: LogLevel | "none") { |
| 1162 | return defineHandlerFor<Logging>().with((self) => { |
no test coverage detected