This allows a logger to be specified in the execution context. If LogService sees this, it will perform its usual logging but also call the injected logger.
@@ -112,6 +112,11 @@ class LogContext {
typeof fields[k].toLogFields === 'function'
) fields[k] = fields[k].toLogFields();
}
+ if ( Context.get('injected_logger') ) {
+ Context.get('injected_logger').log(
+ message + (fields ? ('; fields: ' + JSON.stringify(fields)) : ''),
+ );
+ }
this.logService.log_(
log_level,
this.crumbs,
@@ -134,7 +134,9 @@ class CommandService extends BaseService {
* @returns {Promise<void>}
* @throws {Error} If command execution fails
*/
- await globalThis.root_context.arun(async () => {
+ await globalThis.root_context.sub({
+ injected_logger: log,
+ }).arun(async () => {
await command.execute(commandArgs, log);
});