CompositeLogger

Aggregates all loggers from component references under a single component.

Implements: IReferenceable

Extends: Logger

Description

The CompositeLogger class allows you to aggregate loggers from component references into a single component.

Important points

  • It allows to log messages and conveniently send them to multiple destinations.

References

  • *:logger:*:*:1.0 - (optional) ILogger components to pass log messages

Constructors

Creates a new instance of the logger.

CompositeLogger([IReferences? references])

  • references: IReferences? - references to locate the component dependencies.

Instance methods

setReferences

Sets references to dependent components.

@override

void setReferences(IReferences references)

  • references: IReferences - references to locate the component’s dependencies.

write

Writes a log message to the logger destination.

void write(LogLevel level, String? correlationId, Exception? error, String message)

  • level: LogLevel - log level.
  • correlationId: String? - (optional) transaction id used to trace execution through a call chain.
  • error: Exception? - error object associated with this message.
  • message: String - human-readable message to log.

Examples

MyComponent implements IConfigurable, IReferenceable {
    var _logger = new CompositeLogger();
   void configure(ConfigParams config) {
       _logger.configure(config);
       ...
   }
   void setReferences(IReferences references) {
       _logger.setReferences(references);
       ...
   }
   myMethod(String? correlationId) {
       _logger.debug(correlationId, 'Called method mycomponent.mymethod');
       ...
   }
}

See also