1 | /** @module log */
|
2 | import { IReferences } from 'pip-services3-commons-node';
|
3 | import { IReferenceable } from 'pip-services3-commons-node';
|
4 | import { Logger } from './Logger';
|
5 | import { LogLevel } from './LogLevel';
|
6 | /**
|
7 | * Aggregates all loggers from component references under a single component.
|
8 | *
|
9 | * It allows to log messages and conveniently send them to multiple destinations.
|
10 | *
|
11 | * ### References ###
|
12 | *
|
13 | * - <code>\*:logger:\*:\*:1.0</code> (optional) [[ILogger]] components to pass log messages
|
14 | *
|
15 | * @see [[ILogger]]
|
16 | *
|
17 | * ### Example ###
|
18 | *
|
19 | * class MyComponent implements IConfigurable, IReferenceable {
|
20 | * private _logger: CompositeLogger = new CompositeLogger();
|
21 | *
|
22 | * public configure(config: ConfigParams): void {
|
23 | * this._logger.configure(config);
|
24 | * ...
|
25 | * }
|
26 | *
|
27 | * public setReferences(references: IReferences): void {
|
28 | * this._logger.setReferences(references);
|
29 | * ...
|
30 | * }
|
31 | *
|
32 | * public myMethod(string correlationId): void {
|
33 | * this._logger.debug(correlationId, "Called method mycomponent.mymethod");
|
34 | * ...
|
35 | * }
|
36 | * }
|
37 | *
|
38 | */
|
39 | export declare class CompositeLogger extends Logger implements IReferenceable {
|
40 | private readonly _loggers;
|
41 | /**
|
42 | * Creates a new instance of the logger.
|
43 | *
|
44 | * @param references references to locate the component dependencies.
|
45 | */
|
46 | constructor(references?: IReferences);
|
47 | /**
|
48 | * Sets references to dependent components.
|
49 | *
|
50 | * @param references references to locate the component dependencies.
|
51 | */
|
52 | setReferences(references: IReferences): void;
|
53 | /**
|
54 | * Writes a log message to the logger destination(s).
|
55 | *
|
56 | * @param level a log level.
|
57 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
58 | * @param error an error object associated with this message.
|
59 | * @param message a human-readable message to log.
|
60 | */
|
61 | protected write(level: LogLevel, correlationId: string, error: Error, message: string): void;
|
62 | }
|