@aws-amplify/core 4.4.0 → 4.4.1-cloud-logging.7
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 +282 -104
- 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 +6 -0
- package/lib/Logger/ConsoleLogger.js +117 -43
- package/lib/Logger/ConsoleLogger.js.map +1 -1
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Platform/version.js.map +1 -1
- package/lib/Providers/AWSCloudWatchProvider.d.ts +11 -3
- package/lib/Providers/AWSCloudWatchProvider.js +97 -37
- package/lib/Providers/AWSCloudWatchProvider.js.map +1 -1
- package/lib/Providers/AmazonKinesisLoggingProvider.d.ts +13 -0
- package/lib/Providers/AmazonKinesisLoggingProvider.js +30 -0
- package/lib/Providers/AmazonKinesisLoggingProvider.js.map +1 -0
- package/lib/Util/Constants.d.ts +3 -1
- package/lib/Util/Constants.js +5 -0
- package/lib/Util/Constants.js.map +1 -1
- package/lib/Util/Retry.js +1 -1
- package/lib/Util/Retry.js.map +1 -1
- package/lib/types/types.d.ts +13 -0
- package/lib-esm/Logger/ConsoleLogger.d.ts +6 -0
- package/lib-esm/Logger/ConsoleLogger.js +117 -43
- package/lib-esm/Logger/ConsoleLogger.js.map +1 -1
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Platform/version.js.map +1 -1
- package/lib-esm/Providers/AWSCloudWatchProvider.d.ts +11 -3
- package/lib-esm/Providers/AWSCloudWatchProvider.js +97 -37
- package/lib-esm/Providers/AWSCloudWatchProvider.js.map +1 -1
- package/lib-esm/Providers/AmazonKinesisLoggingProvider.d.ts +13 -0
- package/lib-esm/Providers/AmazonKinesisLoggingProvider.js +28 -0
- package/lib-esm/Providers/AmazonKinesisLoggingProvider.js.map +1 -0
- package/lib-esm/Util/Constants.d.ts +3 -1
- package/lib-esm/Util/Constants.js +4 -1
- package/lib-esm/Util/Constants.js.map +1 -1
- package/lib-esm/Util/Retry.js +1 -1
- package/lib-esm/Util/Retry.js.map +1 -1
- package/lib-esm/types/types.d.ts +13 -0
- package/package.json +3 -2
- package/src/Logger/ConsoleLogger.ts +117 -34
- package/src/Platform/version.ts +1 -1
- package/src/Providers/AWSCloudWatchProvider.ts +112 -18
- package/src/Providers/AmazonKinesisLoggingProvider.ts +43 -0
- package/src/Util/Constants.ts +7 -0
- package/src/Util/Retry.ts +2 -3
- package/src/types/types.ts +79 -62
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
}
|
package/src/Util/Constants.ts
CHANGED
|
@@ -12,11 +12,16 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
// Logging constants
|
|
15
|
+
// Cloudwatch
|
|
15
16
|
const AWS_CLOUDWATCH_BASE_BUFFER_SIZE = 26;
|
|
16
17
|
const AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE = 1048576;
|
|
17
18
|
const AWS_CLOUDWATCH_MAX_EVENT_SIZE = 256000;
|
|
18
19
|
const AWS_CLOUDWATCH_CATEGORY = 'Logging';
|
|
19
20
|
const AWS_CLOUDWATCH_PROVIDER_NAME = 'AWSCloudWatch';
|
|
21
|
+
|
|
22
|
+
const AMAZON_KINESIS_LOGGING_CATEGORY = 'KinesisLogging';
|
|
23
|
+
const AMAZON_KINESIS_LOGGING_PROVIDER_NAME = 'AmazonKinesisLogging';
|
|
24
|
+
|
|
20
25
|
const NO_CREDS_ERROR_STRING = 'No credentials';
|
|
21
26
|
const RETRY_ERROR_CODES = [
|
|
22
27
|
'ResourceNotFoundException',
|
|
@@ -31,4 +36,6 @@ export {
|
|
|
31
36
|
AWS_CLOUDWATCH_PROVIDER_NAME,
|
|
32
37
|
NO_CREDS_ERROR_STRING,
|
|
33
38
|
RETRY_ERROR_CODES,
|
|
39
|
+
AMAZON_KINESIS_LOGGING_PROVIDER_NAME,
|
|
40
|
+
AMAZON_KINESIS_LOGGING_CATEGORY,
|
|
34
41
|
};
|
package/src/Util/Retry.ts
CHANGED
|
@@ -28,9 +28,8 @@ export async function retry(
|
|
|
28
28
|
throw Error('functionToRetry must be a function');
|
|
29
29
|
}
|
|
30
30
|
logger.debug(
|
|
31
|
-
`${
|
|
32
|
-
|
|
33
|
-
} attempt #${attempt} with this vars: ${JSON.stringify(args)}`
|
|
31
|
+
`${functionToRetry.name} attempt #${attempt} with this vars:`,
|
|
32
|
+
args
|
|
34
33
|
);
|
|
35
34
|
|
|
36
35
|
try {
|
package/src/types/types.ts
CHANGED
|
@@ -1,62 +1,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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
+
// pause sending logs
|
|
50
|
+
pause(): void;
|
|
51
|
+
resume(): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface AWSCloudWatchProviderOptions {
|
|
55
|
+
logGroupName?: string;
|
|
56
|
+
logStreamName?: string;
|
|
57
|
+
region?: string;
|
|
58
|
+
credentials?: Credentials;
|
|
59
|
+
endpoint?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface AmplifyConfigure {
|
|
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
|
+
}
|