@aws-amplify/core 4.3.15-cloud-logging.3 → 4.3.15-unstable.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aws-amplify-core.js +102 -246
- package/dist/aws-amplify-core.js.map +1 -1
- package/dist/aws-amplify-core.min.js +6 -6
- package/dist/aws-amplify-core.min.js.map +1 -1
- package/lib/Logger/ConsoleLogger.d.ts +0 -6
- package/lib/Logger/ConsoleLogger.js +43 -118
- package/lib/Logger/ConsoleLogger.js.map +1 -1
- package/lib/Providers/AWSCloudWatchProvider.d.ts +3 -10
- package/lib/Providers/AWSCloudWatchProvider.js +36 -62
- package/lib/Providers/AWSCloudWatchProvider.js.map +1 -1
- package/lib/Util/Constants.d.ts +1 -3
- package/lib/Util/Constants.js +0 -5
- package/lib/Util/Constants.js.map +1 -1
- package/lib/types/types.d.ts +0 -13
- package/lib-esm/Logger/ConsoleLogger.d.ts +0 -6
- package/lib-esm/Logger/ConsoleLogger.js +43 -118
- package/lib-esm/Logger/ConsoleLogger.js.map +1 -1
- package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +3 -10
- package/lib-esm/Providers/AWSCloudWatchProvider.js +36 -62
- package/lib-esm/Providers/AWSCloudWatchProvider.js.map +1 -1
- package/lib-esm/Util/Constants.d.ts +1 -3
- package/lib-esm/Util/Constants.js +1 -4
- package/lib-esm/Util/Constants.js.map +1 -1
- package/lib-esm/types/types.d.ts +0 -13
- package/package.json +3 -4
- package/src/Logger/ConsoleLogger.ts +34 -119
- package/src/Providers/AWSCloudWatchProvider.ts +15 -62
- package/src/Util/Constants.ts +0 -7
- package/src/types/types.ts +62 -79
- package/lib/Providers/AmazonKinesisLoggingProvider.d.ts +0 -13
- package/lib/Providers/AmazonKinesisLoggingProvider.js +0 -30
- package/lib/Providers/AmazonKinesisLoggingProvider.js.map +0 -1
- package/lib-esm/Providers/AmazonKinesisLoggingProvider.d.ts +0 -13
- package/lib-esm/Providers/AmazonKinesisLoggingProvider.js +0 -28
- package/lib-esm/Providers/AmazonKinesisLoggingProvider.js.map +0 -1
- package/src/Providers/AmazonKinesisLoggingProvider.ts +0 -43
|
@@ -24,8 +24,6 @@ const LOG_LEVELS = {
|
|
|
24
24
|
ERROR: 5,
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const COMPATIBLE_PLUGINS = [AWS_CLOUDWATCH_CATEGORY];
|
|
28
|
-
|
|
29
27
|
export enum LOG_TYPE {
|
|
30
28
|
DEBUG = 'DEBUG',
|
|
31
29
|
ERROR = 'ERROR',
|
|
@@ -34,14 +32,6 @@ export enum LOG_TYPE {
|
|
|
34
32
|
VERBOSE = 'VERBOSE',
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
const cloudWatchExcludeList = [
|
|
38
|
-
'AWSCloudWatch',
|
|
39
|
-
'Amplify',
|
|
40
|
-
'Credentials',
|
|
41
|
-
'AuthClass',
|
|
42
|
-
'CloudLogger',
|
|
43
|
-
];
|
|
44
|
-
|
|
45
35
|
/**
|
|
46
36
|
* Write logs
|
|
47
37
|
* @class Logger
|
|
@@ -51,7 +41,6 @@ export class ConsoleLogger implements Logger {
|
|
|
51
41
|
level: LOG_TYPE | string;
|
|
52
42
|
private _pluggables: LoggingProvider[];
|
|
53
43
|
private _config: object;
|
|
54
|
-
private static _globalpluggables: LoggingProvider[] = [];
|
|
55
44
|
|
|
56
45
|
/**
|
|
57
46
|
* @constructor
|
|
@@ -61,21 +50,9 @@ export class ConsoleLogger implements Logger {
|
|
|
61
50
|
this.name = name;
|
|
62
51
|
this.level = level;
|
|
63
52
|
this._pluggables = [];
|
|
64
|
-
this.addPluggable = this.addPluggable.bind(this);
|
|
65
53
|
}
|
|
66
54
|
|
|
67
55
|
static LOG_LEVEL = null;
|
|
68
|
-
static CLOUD_LOG_LEVEL = null;
|
|
69
|
-
static globalPluggables(pluggable: LoggingProvider) {
|
|
70
|
-
if (pluggable && COMPATIBLE_PLUGINS.includes(pluggable.getCategoryName())) {
|
|
71
|
-
ConsoleLogger._globalpluggables.push(pluggable);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static clearGlobalPluggables() {
|
|
76
|
-
ConsoleLogger._globalpluggables = [];
|
|
77
|
-
}
|
|
78
|
-
static connectivity;
|
|
79
56
|
|
|
80
57
|
_padding(n) {
|
|
81
58
|
return n < 10 ? '0' + n : '' + n;
|
|
@@ -100,19 +77,6 @@ export class ConsoleLogger implements Logger {
|
|
|
100
77
|
return this._config;
|
|
101
78
|
}
|
|
102
79
|
|
|
103
|
-
_checkPluggables() {
|
|
104
|
-
if (this._pluggables.length !== ConsoleLogger._globalpluggables.length) {
|
|
105
|
-
if (ConsoleLogger._globalpluggables.length > 0) {
|
|
106
|
-
ConsoleLogger._globalpluggables.forEach(this.addPluggable);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (ConsoleLogger._globalpluggables.length === 0) {
|
|
111
|
-
this._pluggables = [];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
80
|
/**
|
|
117
81
|
* Write log
|
|
118
82
|
* @method
|
|
@@ -121,39 +85,6 @@ export class ConsoleLogger implements Logger {
|
|
|
121
85
|
* @param {string|object} msg - Logging message or object
|
|
122
86
|
*/
|
|
123
87
|
_log(type: LOG_TYPE | string, ...msg) {
|
|
124
|
-
if (!cloudWatchExcludeList.includes(this.name)) {
|
|
125
|
-
this._checkPluggables();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const generateMessage = (msg: any[]): void => {};
|
|
129
|
-
|
|
130
|
-
const generateCloudMessage = (msg: any[]) => {
|
|
131
|
-
let message = '';
|
|
132
|
-
let data;
|
|
133
|
-
|
|
134
|
-
if (msg.length === 1 && typeof msg[0] === 'string') {
|
|
135
|
-
message = msg[0];
|
|
136
|
-
} else if (msg.length === 1) {
|
|
137
|
-
data = msg[0];
|
|
138
|
-
} else if (typeof msg[0] === 'string') {
|
|
139
|
-
let obj = msg.slice(1);
|
|
140
|
-
if (obj.length === 1) {
|
|
141
|
-
obj = obj[0];
|
|
142
|
-
}
|
|
143
|
-
message = msg[0];
|
|
144
|
-
data = obj;
|
|
145
|
-
} else {
|
|
146
|
-
data = msg;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return JSON.stringify({
|
|
150
|
-
level: type,
|
|
151
|
-
class: this.name,
|
|
152
|
-
message,
|
|
153
|
-
data,
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
|
|
157
88
|
let logger_level_name = this.level;
|
|
158
89
|
if (ConsoleLogger.LOG_LEVEL) {
|
|
159
90
|
logger_level_name = ConsoleLogger.LOG_LEVEL;
|
|
@@ -163,60 +94,43 @@ export class ConsoleLogger implements Logger {
|
|
|
163
94
|
}
|
|
164
95
|
const logger_level = LOG_LEVELS[logger_level_name];
|
|
165
96
|
const type_level = LOG_LEVELS[type];
|
|
166
|
-
if (type_level >= logger_level) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
log = console.error.bind(console);
|
|
171
|
-
}
|
|
172
|
-
if (type === LOG_TYPE.WARN && console.warn) {
|
|
173
|
-
log = console.warn.bind(console);
|
|
174
|
-
}
|
|
97
|
+
if (!(type_level >= logger_level)) {
|
|
98
|
+
// Do nothing if type is not greater than or equal to logger level (handle undefined)
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
175
101
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
102
|
+
let log = console.log.bind(console);
|
|
103
|
+
if (type === LOG_TYPE.ERROR && console.error) {
|
|
104
|
+
log = console.error.bind(console);
|
|
105
|
+
}
|
|
106
|
+
if (type === LOG_TYPE.WARN && console.warn) {
|
|
107
|
+
log = console.warn.bind(console);
|
|
108
|
+
}
|
|
179
109
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
log(`${prefix} - ${message}`, data);
|
|
194
|
-
} else {
|
|
195
|
-
data = msg;
|
|
196
|
-
log(prefix, data);
|
|
110
|
+
const prefix = `[${type}] ${this._ts()} ${this.name}`;
|
|
111
|
+
let message = '';
|
|
112
|
+
|
|
113
|
+
if (msg.length === 1 && typeof msg[0] === 'string') {
|
|
114
|
+
message = `${prefix} - ${msg[0]}`;
|
|
115
|
+
log(message);
|
|
116
|
+
} else if (msg.length === 1) {
|
|
117
|
+
message = `${prefix} ${msg[0]}`;
|
|
118
|
+
log(prefix, msg[0]);
|
|
119
|
+
} else if (typeof msg[0] === 'string') {
|
|
120
|
+
let obj = msg.slice(1);
|
|
121
|
+
if (obj.length === 1) {
|
|
122
|
+
obj = obj[0];
|
|
197
123
|
}
|
|
124
|
+
message = `${prefix} - ${msg[0]} ${obj}`;
|
|
125
|
+
log(`${prefix} - ${msg[0]}`, obj);
|
|
126
|
+
} else {
|
|
127
|
+
message = `${prefix} ${msg}`;
|
|
128
|
+
log(prefix, msg);
|
|
198
129
|
}
|
|
199
130
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
) {
|
|
204
|
-
const cloudMessage = generateCloudMessage(msg);
|
|
205
|
-
for (const plugin of this._pluggables) {
|
|
206
|
-
const logger_level = LOG_LEVELS[ConsoleLogger.CLOUD_LOG_LEVEL];
|
|
207
|
-
const type_level = LOG_LEVELS[type];
|
|
208
|
-
|
|
209
|
-
const logEvent: InputLogEvent = {
|
|
210
|
-
message: cloudMessage,
|
|
211
|
-
timestamp: Date.now(),
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
if (type_level >= logger_level) {
|
|
215
|
-
plugin.pushLogs([logEvent]);
|
|
216
|
-
} else {
|
|
217
|
-
plugin.pushLogs([]);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
131
|
+
for (const plugin of this._pluggables) {
|
|
132
|
+
const logEvent: InputLogEvent = { message, timestamp: Date.now() };
|
|
133
|
+
plugin.pushLogs([logEvent]);
|
|
220
134
|
}
|
|
221
135
|
}
|
|
222
136
|
|
|
@@ -281,8 +195,9 @@ export class ConsoleLogger implements Logger {
|
|
|
281
195
|
}
|
|
282
196
|
|
|
283
197
|
addPluggable(pluggable: LoggingProvider) {
|
|
284
|
-
if (pluggable &&
|
|
198
|
+
if (pluggable && pluggable.getCategoryName() === AWS_CLOUDWATCH_CATEGORY) {
|
|
285
199
|
this._pluggables.push(pluggable);
|
|
200
|
+
pluggable.configure(this._config);
|
|
286
201
|
}
|
|
287
202
|
}
|
|
288
203
|
|
|
@@ -39,7 +39,6 @@ import {
|
|
|
39
39
|
AWSCloudWatchProviderOptions,
|
|
40
40
|
CloudWatchDataTracker,
|
|
41
41
|
LoggingProvider,
|
|
42
|
-
AmplifyConfigure,
|
|
43
42
|
} from '../types/types';
|
|
44
43
|
import { Credentials } from '../..';
|
|
45
44
|
import { ConsoleLogger as Logger } from '../Logger';
|
|
@@ -55,15 +54,8 @@ import {
|
|
|
55
54
|
RETRY_ERROR_CODES,
|
|
56
55
|
} from '../Util/Constants';
|
|
57
56
|
|
|
58
|
-
if (
|
|
59
|
-
typeof window === 'undefined' ||
|
|
60
|
-
(typeof window === 'object' && !window.TextEncoder)
|
|
61
|
-
) {
|
|
62
|
-
require('fast-text-encoding');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
57
|
const logger = new Logger('AWSCloudWatch');
|
|
66
|
-
|
|
58
|
+
|
|
67
59
|
class AWSCloudWatchProvider implements LoggingProvider {
|
|
68
60
|
static readonly PROVIDER_NAME = AWS_CLOUDWATCH_PROVIDER_NAME;
|
|
69
61
|
static readonly CATEGORY = AWS_CLOUDWATCH_CATEGORY;
|
|
@@ -73,29 +65,17 @@ class AWSCloudWatchProvider implements LoggingProvider {
|
|
|
73
65
|
private _currentLogBatch: InputLogEvent[];
|
|
74
66
|
private _timer;
|
|
75
67
|
private _nextSequenceToken: string | undefined;
|
|
76
|
-
private _processing: boolean;
|
|
77
|
-
private _initialized = false;
|
|
78
|
-
private _preFlightCheck: () => Promise<boolean>;
|
|
79
|
-
|
|
80
|
-
constructor(config?: AmplifyConfigure) {
|
|
81
|
-
console.log('cstr', config);
|
|
82
|
-
if (!this._initialized) {
|
|
83
|
-
this.configure(config);
|
|
84
|
-
|
|
85
|
-
this._dataTracker = {
|
|
86
|
-
eventUploadInProgress: false,
|
|
87
|
-
logEvents: [],
|
|
88
|
-
verifiedLogGroup: { logGroupName: this._config.logGroupName },
|
|
89
|
-
};
|
|
90
68
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
69
|
+
constructor(config?: AWSCloudWatchProviderOptions) {
|
|
70
|
+
this.configure(config);
|
|
71
|
+
this._dataTracker = {
|
|
72
|
+
eventUploadInProgress: false,
|
|
73
|
+
logEvents: [],
|
|
74
|
+
};
|
|
75
|
+
this._currentLogBatch = [];
|
|
76
|
+
this._initiateLogPushInterval();
|
|
95
77
|
}
|
|
96
78
|
|
|
97
|
-
// public static instance: AWSCloudWatchProvider;
|
|
98
|
-
|
|
99
79
|
public getProviderName(): string {
|
|
100
80
|
return AWSCloudWatchProvider.PROVIDER_NAME;
|
|
101
81
|
}
|
|
@@ -108,13 +88,9 @@ class AWSCloudWatchProvider implements LoggingProvider {
|
|
|
108
88
|
return this._dataTracker.logEvents;
|
|
109
89
|
}
|
|
110
90
|
|
|
111
|
-
public
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public configure(config?: AmplifyConfigure): AWSCloudWatchProviderOptions {
|
|
91
|
+
public configure(
|
|
92
|
+
config?: AWSCloudWatchProviderOptions
|
|
93
|
+
): AWSCloudWatchProviderOptions {
|
|
118
94
|
if (!config) return this._config || {};
|
|
119
95
|
|
|
120
96
|
const conf = Object.assign(
|
|
@@ -241,25 +217,8 @@ class AWSCloudWatchProvider implements LoggingProvider {
|
|
|
241
217
|
}
|
|
242
218
|
|
|
243
219
|
public pushLogs(logs: InputLogEvent[]): void {
|
|
244
|
-
logger.debug('pushing log events to Cloudwatch
|
|
245
|
-
this._dataTracker.logEvents = this._dataTracker.logEvents
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public pause() {
|
|
249
|
-
this._processing = false;
|
|
250
|
-
if (this._timer) {
|
|
251
|
-
clearInterval(this._timer);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
public resume() {
|
|
256
|
-
this._processing = true;
|
|
257
|
-
this._initiateLogPushInterval();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
public clear() {
|
|
261
|
-
this._dataTracker.logEvents = [];
|
|
262
|
-
this._currentLogBatch = [];
|
|
220
|
+
logger.debug('pushing log events to Cloudwatch...');
|
|
221
|
+
this._dataTracker.logEvents = [...this._dataTracker.logEvents, ...logs];
|
|
263
222
|
}
|
|
264
223
|
|
|
265
224
|
private async _validateLogGroupExistsAndCreate(
|
|
@@ -435,11 +394,6 @@ class AWSCloudWatchProvider implements LoggingProvider {
|
|
|
435
394
|
* We also need to ensure that the logs in the batch are sorted in chronological order.
|
|
436
395
|
* https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
|
|
437
396
|
*/
|
|
438
|
-
if (!(await this._preFlightCheck())) {
|
|
439
|
-
this.clear();
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
397
|
const seqToken = await this._getNextSequenceToken();
|
|
444
398
|
const logBatch =
|
|
445
399
|
this._currentLogBatch.length === 0
|
|
@@ -555,9 +509,8 @@ class AWSCloudWatchProvider implements LoggingProvider {
|
|
|
555
509
|
logger.error(
|
|
556
510
|
`error when calling _safeUploadLogEvents in the timer interval - ${err}`
|
|
557
511
|
);
|
|
558
|
-
this.pause();
|
|
559
512
|
}
|
|
560
|
-
},
|
|
513
|
+
}, 2000);
|
|
561
514
|
}
|
|
562
515
|
|
|
563
516
|
private _getDocUploadPermissibility(): boolean {
|
package/src/Util/Constants.ts
CHANGED
|
@@ -12,16 +12,11 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
// Logging constants
|
|
15
|
-
// Cloudwatch
|
|
16
15
|
const AWS_CLOUDWATCH_BASE_BUFFER_SIZE = 26;
|
|
17
16
|
const AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE = 1048576;
|
|
18
17
|
const AWS_CLOUDWATCH_MAX_EVENT_SIZE = 256000;
|
|
19
18
|
const AWS_CLOUDWATCH_CATEGORY = 'Logging';
|
|
20
19
|
const AWS_CLOUDWATCH_PROVIDER_NAME = 'AWSCloudWatch';
|
|
21
|
-
|
|
22
|
-
const AMAZON_KINESIS_LOGGING_CATEGORY = 'KinesisLogging';
|
|
23
|
-
const AMAZON_KINESIS_LOGGING_PROVIDER_NAME = 'AmazonKinesisLogging';
|
|
24
|
-
|
|
25
20
|
const NO_CREDS_ERROR_STRING = 'No credentials';
|
|
26
21
|
const RETRY_ERROR_CODES = [
|
|
27
22
|
'ResourceNotFoundException',
|
|
@@ -36,6 +31,4 @@ export {
|
|
|
36
31
|
AWS_CLOUDWATCH_PROVIDER_NAME,
|
|
37
32
|
NO_CREDS_ERROR_STRING,
|
|
38
33
|
RETRY_ERROR_CODES,
|
|
39
|
-
AMAZON_KINESIS_LOGGING_PROVIDER_NAME,
|
|
40
|
-
AMAZON_KINESIS_LOGGING_CATEGORY,
|
|
41
34
|
};
|
package/src/types/types.ts
CHANGED
|
@@ -1,79 +1,62 @@
|
|
|
1
|
-
import { InputLogEvent, LogGroup } from '@aws-sdk/client-cloudwatch-logs';
|
|
2
|
-
import { Credentials } from '@aws-sdk/types';
|
|
3
|
-
|
|
4
|
-
export interface AmplifyConfig {
|
|
5
|
-
Analytics?: object;
|
|
6
|
-
Auth?: object;
|
|
7
|
-
API?: object;
|
|
8
|
-
Logging?: object;
|
|
9
|
-
Storage?: object;
|
|
10
|
-
Cache?: object;
|
|
11
|
-
Geo?: object;
|
|
12
|
-
ssr?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ICredentials {
|
|
16
|
-
accessKeyId: string;
|
|
17
|
-
sessionToken: string;
|
|
18
|
-
secretAccessKey: string;
|
|
19
|
-
identityId: string;
|
|
20
|
-
authenticated: boolean;
|
|
21
|
-
// Long term creds do not provide an expiration date
|
|
22
|
-
expiration?: Date;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @private
|
|
27
|
-
* Internal use of Amplify only
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
export type DelayFunction = (
|
|
31
|
-
attempt: number,
|
|
32
|
-
args?: any[],
|
|
33
|
-
error?: Error
|
|
34
|
-
) => number | false;
|
|
35
|
-
|
|
36
|
-
export interface LoggingProvider {
|
|
37
|
-
// return the name of you provider
|
|
38
|
-
getProviderName(): string;
|
|
39
|
-
|
|
40
|
-
// return the name of you category
|
|
41
|
-
getCategoryName(): string;
|
|
42
|
-
|
|
43
|
-
// configure the plugin
|
|
44
|
-
configure(config?: object): object;
|
|
45
|
-
|
|
46
|
-
// take logs and push to provider
|
|
47
|
-
pushLogs(logs: InputLogEvent[]): void;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Logging: {
|
|
64
|
-
logGroupName: string;
|
|
65
|
-
logStreamName: string;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface CloudWatchDataTracker {
|
|
70
|
-
eventUploadInProgress: boolean;
|
|
71
|
-
logEvents: InputLogEvent[];
|
|
72
|
-
verifiedLogGroup?: LogGroup;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface AmazonKinesisLoggerOptions {
|
|
76
|
-
region?: string;
|
|
77
|
-
credentials?: Credentials;
|
|
78
|
-
endpoint?: string;
|
|
79
|
-
}
|
|
1
|
+
import { InputLogEvent, LogGroup } from '@aws-sdk/client-cloudwatch-logs';
|
|
2
|
+
import { Credentials } from '@aws-sdk/types';
|
|
3
|
+
|
|
4
|
+
export interface AmplifyConfig {
|
|
5
|
+
Analytics?: object;
|
|
6
|
+
Auth?: object;
|
|
7
|
+
API?: object;
|
|
8
|
+
Logging?: object;
|
|
9
|
+
Storage?: object;
|
|
10
|
+
Cache?: object;
|
|
11
|
+
Geo?: object;
|
|
12
|
+
ssr?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ICredentials {
|
|
16
|
+
accessKeyId: string;
|
|
17
|
+
sessionToken: string;
|
|
18
|
+
secretAccessKey: string;
|
|
19
|
+
identityId: string;
|
|
20
|
+
authenticated: boolean;
|
|
21
|
+
// Long term creds do not provide an expiration date
|
|
22
|
+
expiration?: Date;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
* Internal use of Amplify only
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export type DelayFunction = (
|
|
31
|
+
attempt: number,
|
|
32
|
+
args?: any[],
|
|
33
|
+
error?: Error
|
|
34
|
+
) => number | false;
|
|
35
|
+
|
|
36
|
+
export interface LoggingProvider {
|
|
37
|
+
// return the name of you provider
|
|
38
|
+
getProviderName(): string;
|
|
39
|
+
|
|
40
|
+
// return the name of you category
|
|
41
|
+
getCategoryName(): string;
|
|
42
|
+
|
|
43
|
+
// configure the plugin
|
|
44
|
+
configure(config?: object): object;
|
|
45
|
+
|
|
46
|
+
// take logs and push to provider
|
|
47
|
+
pushLogs(logs: InputLogEvent[]): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface AWSCloudWatchProviderOptions {
|
|
51
|
+
logGroupName?: string;
|
|
52
|
+
logStreamName?: string;
|
|
53
|
+
region?: string;
|
|
54
|
+
credentials?: Credentials;
|
|
55
|
+
endpoint?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface CloudWatchDataTracker {
|
|
59
|
+
eventUploadInProgress: boolean;
|
|
60
|
+
logEvents: InputLogEvent[];
|
|
61
|
+
verifiedLogGroup?: LogGroup;
|
|
62
|
+
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AmazonKinesisLoggerOptions, LoggingProvider } from '../types/types';
|
|
2
|
-
export declare class AmazonKinesisLoggingProvider implements LoggingProvider {
|
|
3
|
-
static readonly PROVIDER_NAME = "AmazonKinesisLogging";
|
|
4
|
-
static readonly CATEGORY = "KinesisLogging";
|
|
5
|
-
private _config;
|
|
6
|
-
constructor(config?: AmazonKinesisLoggerOptions);
|
|
7
|
-
getProviderName(): string;
|
|
8
|
-
getCategoryName(): string;
|
|
9
|
-
configure(config?: AmazonKinesisLoggerOptions): AmazonKinesisLoggerOptions;
|
|
10
|
-
pushLogs(logs: any[]): void;
|
|
11
|
-
pause(): void;
|
|
12
|
-
resume(): void;
|
|
13
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var Logger_1 = require("../Logger");
|
|
4
|
-
var Constants_1 = require("../Util/Constants");
|
|
5
|
-
var logger = new Logger_1.ConsoleLogger('AmazonKinesisLoggingProvider');
|
|
6
|
-
var AmazonKinesisLoggingProvider = /** @class */ (function () {
|
|
7
|
-
function AmazonKinesisLoggingProvider(config) {
|
|
8
|
-
}
|
|
9
|
-
AmazonKinesisLoggingProvider.prototype.getProviderName = function () {
|
|
10
|
-
return AmazonKinesisLoggingProvider.PROVIDER_NAME;
|
|
11
|
-
};
|
|
12
|
-
AmazonKinesisLoggingProvider.prototype.getCategoryName = function () {
|
|
13
|
-
return AmazonKinesisLoggingProvider.CATEGORY;
|
|
14
|
-
};
|
|
15
|
-
AmazonKinesisLoggingProvider.prototype.configure = function (config) {
|
|
16
|
-
if (!config)
|
|
17
|
-
return this._config || {};
|
|
18
|
-
return this._config;
|
|
19
|
-
};
|
|
20
|
-
AmazonKinesisLoggingProvider.prototype.pushLogs = function (logs) {
|
|
21
|
-
logger.debug('pushing log events to Kinesis...');
|
|
22
|
-
};
|
|
23
|
-
AmazonKinesisLoggingProvider.prototype.pause = function () { };
|
|
24
|
-
AmazonKinesisLoggingProvider.prototype.resume = function () { };
|
|
25
|
-
AmazonKinesisLoggingProvider.PROVIDER_NAME = Constants_1.AMAZON_KINESIS_LOGGING_PROVIDER_NAME;
|
|
26
|
-
AmazonKinesisLoggingProvider.CATEGORY = Constants_1.AMAZON_KINESIS_LOGGING_CATEGORY;
|
|
27
|
-
return AmazonKinesisLoggingProvider;
|
|
28
|
-
}());
|
|
29
|
-
exports.AmazonKinesisLoggingProvider = AmazonKinesisLoggingProvider;
|
|
30
|
-
//# sourceMappingURL=AmazonKinesisLoggingProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AmazonKinesisLoggingProvider.js","sourceRoot":"","sources":["../../src/Providers/AmazonKinesisLoggingProvider.ts"],"names":[],"mappings":";;AACA,oCAAoD;AACpD,+CAK2B;AAE3B,IAAM,MAAM,GAAG,IAAI,sBAAM,CAAC,8BAA8B,CAAC,CAAC;AAE1D;IAMC,sCAAY,MAAmC;IAAG,CAAC;IAE5C,sDAAe,GAAtB;QACC,OAAO,4BAA4B,CAAC,aAAa,CAAC;IACnD,CAAC;IAEM,sDAAe,GAAtB;QACC,OAAO,4BAA4B,CAAC,QAAQ,CAAC;IAC9C,CAAC;IAEM,gDAAS,GAAhB,UACC,MAAmC;QAEnC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QAEvC,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,+CAAQ,GAAf,UAAgB,IAAW;QAC1B,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAClD,CAAC;IAEM,4CAAK,GAAZ,cAAgB,CAAC;IAEV,6CAAM,GAAb,cAAiB,CAAC;IA7BF,0CAAa,GAAG,gDAAoC,CAAC;IACrD,qCAAQ,GAAG,2CAA+B,CAAC;IA6B5D,mCAAC;CAAA,AA/BD,IA+BC;AA/BY,oEAA4B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AmazonKinesisLoggerOptions, LoggingProvider } from '../types/types';
|
|
2
|
-
export declare class AmazonKinesisLoggingProvider implements LoggingProvider {
|
|
3
|
-
static readonly PROVIDER_NAME = "AmazonKinesisLogging";
|
|
4
|
-
static readonly CATEGORY = "KinesisLogging";
|
|
5
|
-
private _config;
|
|
6
|
-
constructor(config?: AmazonKinesisLoggerOptions);
|
|
7
|
-
getProviderName(): string;
|
|
8
|
-
getCategoryName(): string;
|
|
9
|
-
configure(config?: AmazonKinesisLoggerOptions): AmazonKinesisLoggerOptions;
|
|
10
|
-
pushLogs(logs: any[]): void;
|
|
11
|
-
pause(): void;
|
|
12
|
-
resume(): void;
|
|
13
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ConsoleLogger as Logger } from '../Logger';
|
|
2
|
-
import { AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY, } from '../Util/Constants';
|
|
3
|
-
var logger = new Logger('AmazonKinesisLoggingProvider');
|
|
4
|
-
var AmazonKinesisLoggingProvider = /** @class */ (function () {
|
|
5
|
-
function AmazonKinesisLoggingProvider(config) {
|
|
6
|
-
}
|
|
7
|
-
AmazonKinesisLoggingProvider.prototype.getProviderName = function () {
|
|
8
|
-
return AmazonKinesisLoggingProvider.PROVIDER_NAME;
|
|
9
|
-
};
|
|
10
|
-
AmazonKinesisLoggingProvider.prototype.getCategoryName = function () {
|
|
11
|
-
return AmazonKinesisLoggingProvider.CATEGORY;
|
|
12
|
-
};
|
|
13
|
-
AmazonKinesisLoggingProvider.prototype.configure = function (config) {
|
|
14
|
-
if (!config)
|
|
15
|
-
return this._config || {};
|
|
16
|
-
return this._config;
|
|
17
|
-
};
|
|
18
|
-
AmazonKinesisLoggingProvider.prototype.pushLogs = function (logs) {
|
|
19
|
-
logger.debug('pushing log events to Kinesis...');
|
|
20
|
-
};
|
|
21
|
-
AmazonKinesisLoggingProvider.prototype.pause = function () { };
|
|
22
|
-
AmazonKinesisLoggingProvider.prototype.resume = function () { };
|
|
23
|
-
AmazonKinesisLoggingProvider.PROVIDER_NAME = AMAZON_KINESIS_LOGGING_PROVIDER_NAME;
|
|
24
|
-
AmazonKinesisLoggingProvider.CATEGORY = AMAZON_KINESIS_LOGGING_CATEGORY;
|
|
25
|
-
return AmazonKinesisLoggingProvider;
|
|
26
|
-
}());
|
|
27
|
-
export { AmazonKinesisLoggingProvider };
|
|
28
|
-
//# sourceMappingURL=AmazonKinesisLoggingProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AmazonKinesisLoggingProvider.js","sourceRoot":"","sources":["../../src/Providers/AmazonKinesisLoggingProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EACN,oCAAoC,EACpC,+BAA+B,GAG/B,MAAM,mBAAmB,CAAC;AAE3B,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,8BAA8B,CAAC,CAAC;AAE1D;IAMC,sCAAY,MAAmC;IAAG,CAAC;IAE5C,sDAAe,GAAtB;QACC,OAAO,4BAA4B,CAAC,aAAa,CAAC;IACnD,CAAC;IAEM,sDAAe,GAAtB;QACC,OAAO,4BAA4B,CAAC,QAAQ,CAAC;IAC9C,CAAC;IAEM,gDAAS,GAAhB,UACC,MAAmC;QAEnC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QAEvC,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,+CAAQ,GAAf,UAAgB,IAAW;QAC1B,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAClD,CAAC;IAEM,4CAAK,GAAZ,cAAgB,CAAC;IAEV,6CAAM,GAAb,cAAiB,CAAC;IA7BF,0CAAa,GAAG,oCAAoC,CAAC;IACrD,qCAAQ,GAAG,+BAA+B,CAAC;IA6B5D,mCAAC;CAAA,AA/BD,IA+BC;SA/BY,4BAA4B"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AmazonKinesisLoggerOptions, LoggingProvider } from '../types/types';
|
|
2
|
-
import { ConsoleLogger as Logger } from '../Logger';
|
|
3
|
-
import {
|
|
4
|
-
AMAZON_KINESIS_LOGGING_PROVIDER_NAME,
|
|
5
|
-
AMAZON_KINESIS_LOGGING_CATEGORY,
|
|
6
|
-
NO_CREDS_ERROR_STRING,
|
|
7
|
-
RETRY_ERROR_CODES,
|
|
8
|
-
} from '../Util/Constants';
|
|
9
|
-
|
|
10
|
-
const logger = new Logger('AmazonKinesisLoggingProvider');
|
|
11
|
-
|
|
12
|
-
export class AmazonKinesisLoggingProvider implements LoggingProvider {
|
|
13
|
-
static readonly PROVIDER_NAME = AMAZON_KINESIS_LOGGING_PROVIDER_NAME;
|
|
14
|
-
static readonly CATEGORY = AMAZON_KINESIS_LOGGING_CATEGORY;
|
|
15
|
-
|
|
16
|
-
private _config: AmazonKinesisLoggerOptions;
|
|
17
|
-
|
|
18
|
-
constructor(config?: AmazonKinesisLoggerOptions) {}
|
|
19
|
-
|
|
20
|
-
public getProviderName(): string {
|
|
21
|
-
return AmazonKinesisLoggingProvider.PROVIDER_NAME;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public getCategoryName(): string {
|
|
25
|
-
return AmazonKinesisLoggingProvider.CATEGORY;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public configure(
|
|
29
|
-
config?: AmazonKinesisLoggerOptions
|
|
30
|
-
): AmazonKinesisLoggerOptions {
|
|
31
|
-
if (!config) return this._config || {};
|
|
32
|
-
|
|
33
|
-
return this._config;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public pushLogs(logs: any[]): void {
|
|
37
|
-
logger.debug('pushing log events to Kinesis...');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public pause() {}
|
|
41
|
-
|
|
42
|
-
public resume() {}
|
|
43
|
-
}
|