-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathlogging.ts
58 lines (53 loc) · 1.42 KB
/
logging.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* Properties used to initialize Logging.
*/
export interface LoggingProps {
/**
* Whether or not to log data associated with the API call response.
*
* @default true
*/
readonly logApiResponseData?: boolean;
}
/**
* A class used to configure Logging during AwsCustomResource SDK calls.
*/
export abstract class Logging {
/**
* Enables logging of all logged data in the lambda handler.
*
* This includes the event object, the API call response, all fields in the response object
* returned by the lambda, and any errors encountered.
*/
public static all(): Logging {
return new (class extends Logging {
public constructor() {
super();
}
})();
}
/**
* Hides logging of data associated with the API call response. This includes hiding the raw API
* call response and the `Data` field associated with the lambda handler response.
*/
public static withDataHidden(): Logging {
return new (class extends Logging {
public constructor() {
super({ logApiResponseData: false });
}
})();
}
/**
* Whether or not to log data associated with the API call response.
*/
private logApiResponseData?: boolean;
protected constructor(props: LoggingProps = {}) {
this.logApiResponseData = props.logApiResponseData ?? true;
}
/**
* @internal
*/
public _render() {
return { logApiResponseData: this.logApiResponseData };
}
}