1 | import { IReferenceable } from 'pip-services3-commons-node';
|
2 | import { LogLevel } from 'pip-services3-components-node';
|
3 | import { IReferences } from 'pip-services3-commons-node';
|
4 | import { IOpenable } from 'pip-services3-commons-node';
|
5 | import { CachedLogger } from 'pip-services3-components-node';
|
6 | import { LogMessage } from 'pip-services3-components-node';
|
7 | import { ConfigParams } from 'pip-services3-commons-node';
|
8 | /**
|
9 | * Logger that writes log messages to AWS Cloud Watch Log.
|
10 | *
|
11 | * ### Configuration parameters ###
|
12 | *
|
13 | * - stream: (optional) Cloud Watch Log stream (default: context name)
|
14 | * - group: (optional) Cloud Watch Log group (default: context instance ID or hostname)
|
15 | * - connections:
|
16 | * - discovery_key: (optional) a key to retrieve the connection from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]]
|
17 | * - region: (optional) AWS region
|
18 | * - credentials:
|
19 | * - store_key: (optional) a key to retrieve the credentials from [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/auth.icredentialstore.html ICredentialStore]]
|
20 | * - access_id: AWS access/client id
|
21 | * - access_key: AWS access/client id
|
22 | * - options:
|
23 | * - interval: interval in milliseconds to save current counters measurements (default: 5 mins)
|
24 | * - reset_timeout: timeout in milliseconds to reset the counters. 0 disables the reset (default: 0)
|
25 | *
|
26 | * ### References ###
|
27 | *
|
28 | * - <code>\*:context-info:\*:\*:1.0</code> (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/classes/info.contextinfo.html ContextInfo]] to detect the context id and specify counters source
|
29 | * - <code>\*:discovery:\*:\*:1.0</code> (optional) [[https://pip-services3-node.github.io/pip-services3-components-node/interfaces/connect.idiscovery.html IDiscovery]] services to resolve connections
|
30 | * - <code>\*:credential-store:\*:\*:1.0</code> (optional) Credential stores to resolve credentials
|
31 | *
|
32 | * @see [[https://pip-services3-node.github.io/pip-services3-components-node/classes/count.counter.html Counter]] (in the Pip.Services components package)
|
33 | * @see [[https://pip-services3-node.github.io/pip-services3-components-node/classes/count.cachedcounters.html CachedCounters]] (in the Pip.Services components package)
|
34 | * @see [[https://pip-services3-node.github.io/pip-services3-components-node/classes/log.compositelogger.html CompositeLogger]] (in the Pip.Services components package)
|
35 |
|
36 | *
|
37 | * ### Example ###
|
38 | *
|
39 | * let logger = new Logger();
|
40 | * logger.config(ConfigParams.fromTuples(
|
41 | * "stream", "mystream",
|
42 | * "group", "mygroup",
|
43 | * "connection.region", "us-east-1",
|
44 | * "connection.access_id", "XXXXXXXXXXX",
|
45 | * "connection.access_key", "XXXXXXXXXXX"
|
46 | * ));
|
47 | * logger.setReferences(References.fromTuples(
|
48 | * new Descriptor("pip-services", "logger", "console", "default", "1.0"),
|
49 | * new ConsoleLogger()
|
50 | * ));
|
51 | *
|
52 | * logger.open("123", (err) => {
|
53 | * ...
|
54 | * });
|
55 | *
|
56 | * logger.setLevel(LogLevel.debug);
|
57 | *
|
58 | * logger.error("123", ex, "Error occured: %s", ex.message);
|
59 | * logger.debug("123", "Everything is OK.");
|
60 | */
|
61 | export declare class CloudWatchLogger extends CachedLogger implements IReferenceable, IOpenable {
|
62 | private _timer;
|
63 | private _connectionResolver;
|
64 | private _client;
|
65 | private _connection;
|
66 | private _connectTimeout;
|
67 | private _group;
|
68 | private _stream;
|
69 | private _lastToken;
|
70 | private _logger;
|
71 | /**
|
72 | * Creates a new instance of this logger.
|
73 | */
|
74 | constructor();
|
75 | /**
|
76 | * Configures component by passing configuration parameters.
|
77 | *
|
78 | * @param config configuration parameters to be set.
|
79 | */
|
80 | configure(config: ConfigParams): void;
|
81 | /**
|
82 | * Sets references to dependent components.
|
83 | *
|
84 | * @param references references to locate the component dependencies.
|
85 | * @see [[https://pip-services3-node.github.io/pip-services3-commons-node/interfaces/refer.ireferences.html IReferences]] (in the Pip.Services commons package)
|
86 | */
|
87 | setReferences(references: IReferences): void;
|
88 | /**
|
89 | * Writes a log message to the logger destination.
|
90 | *
|
91 | * @param level a log level.
|
92 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
93 | * @param error an error object associated with this message.
|
94 | * @param message a human-readable message to log.
|
95 | */
|
96 | protected write(level: LogLevel, correlationId: string, ex: Error, message: string): void;
|
97 | /**
|
98 | * Checks if the component is opened.
|
99 | *
|
100 | * @returns true if the component has been opened and false otherwise.
|
101 | */
|
102 | isOpen(): boolean;
|
103 | /**
|
104 | * Opens the component.
|
105 | *
|
106 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
107 | * @param callback callback function that receives error or null no errors occured.
|
108 | */
|
109 | open(correlationId: string, callback: (err: any) => void): void;
|
110 | /**
|
111 | * Closes component and frees used resources.
|
112 | *
|
113 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
114 | * @param callback callback function that receives error or null no errors occured.
|
115 | */
|
116 | close(correlationId: string, callback: (err: any) => void): void;
|
117 | private formatMessageText;
|
118 | /**
|
119 | * Saves log messages from the cache.
|
120 | *
|
121 | * @param messages a list with log messages
|
122 | * @param callback callback function that receives error or null for success.
|
123 | */
|
124 | protected save(messages: LogMessage[], callback: (err: any) => void): void;
|
125 | }
|