Skip to content

Commit 09525f4

Browse files
committed
test: add context data, run fmt
1 parent b9968ae commit 09525f4

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

index.test.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function makeLogEvent(): LoggingEvent {
2525
columnNumber: 0,
2626
callStack: "",
2727
functionName: "",
28-
context: null,
28+
context: { sub: "test" },
2929
serialise: () => "",
3030
level: new Level(20000, "INFO", "green"),
3131
};
@@ -114,6 +114,7 @@ describe("AWS Integration", () => {
114114
assert.equal(data.category, "default");
115115
assert.equal(data.level, "INFO");
116116
assert.equal(data.msg, "test");
117+
assert.equal(data.sub, "test"); // from context
117118
}
118119
});
119120
});

index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ import {
55
} from "@aws-sdk/client-cloudwatch-logs";
66
import { layout as jsonLayout } from "log4js-layout-json";
77

8-
import type { RegionInputConfig } from "@smithy/config-resolver/dist-types/regionConfig/resolveRegionConfig";
9-
import type { AwsCredentialIdentity } from "@smithy/types/dist-types/identity/awsCredentialIdentity";
8+
import type {
9+
RegionInputConfig,
10+
} from "@smithy/config-resolver/dist-types/regionConfig/resolveRegionConfig";
11+
import type {
12+
AwsCredentialIdentity,
13+
} from "@smithy/types/dist-types/identity/awsCredentialIdentity";
1014
import type log4js from "log4js";
1115

1216
export interface Config
@@ -124,7 +128,7 @@ export function cloudwatch(
124128
if (config.createResources) {
125129
cloudwatch.createLogGroup({
126130
logGroupName: config.logGroupName,
127-
}).catch(error => {
131+
}).catch((error) => {
128132
if (error.name === "ResourceAlreadyExistsException") {
129133
// TODO: continue or exit
130134
}
@@ -133,7 +137,7 @@ export function cloudwatch(
133137
cloudwatch.createLogStream({
134138
logGroupName: config.logGroupName,
135139
logStreamName: config.logStreamName,
136-
}).catch(error => {
140+
}).catch((error) => {
137141
if (error.name === "ResourceAlreadyExistsException") {
138142
// TODO: continue or exit
139143
}
@@ -154,7 +158,7 @@ export function cloudwatch(
154158
if (streams.logStreams?.length) {
155159
const stream = streams
156160
.logStreams
157-
.find(s => s.logStreamName === config.logStreamName);
161+
.find((s) => s.logStreamName === config.logStreamName);
158162

159163
if (stream === undefined) {
160164
throw new ConfigError("Stream name doesn't exists");

0 commit comments

Comments
 (0)