Skip to content

Commit 4fe9af8

Browse files
committed
chore(logger): refactor types and interfaces (#1758)
* chore(logger): refactor types and interfaces * chore: grouped type files * chore: fix code smell * chore: fix ci * chore: fix ci
1 parent f07ff0d commit 4fe9af8

File tree

8 files changed

+7
-141
lines changed

8 files changed

+7
-141
lines changed

packages/logger/src/Logger.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ class Logger extends Utility implements LoggerInterface {
432432
logger.addContext(context);
433433

434434
let shouldLogEvent = undefined;
435-
if (options && options.hasOwnProperty('logEvent')) {
436-
shouldLogEvent = options.logEvent;
435+
if (Object.hasOwn(options || {}, 'logEvent')) {
436+
shouldLogEvent = options!.logEvent;
437437
}
438438
logger.logEventIfEnabled(event, shouldLogEvent);
439439
}

packages/logger/src/formatter/LogFormatter.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@ abstract class LogFormatter implements LogFormatterInterface {
6565
location: this.getCodeLocation(error.stack),
6666
message: error.message,
6767
stack: error.stack,
68-
cause: isErrorWithCause(error)
69-
? error.cause instanceof Error
68+
cause:
69+
error.cause instanceof Error
7070
? this.formatError(error.cause)
71-
: error.cause
72-
: undefined,
71+
: error.cause,
7372
};
7473
}
7574

packages/logger/src/formatter/LogFormatterInterface.ts

-30
This file was deleted.

packages/logger/src/log/LogItemInterface.ts

-9
This file was deleted.

packages/logger/src/types/formats/PowertoolsLog.ts

-93
This file was deleted.

packages/logger/src/types/formats/index.ts

-1
This file was deleted.

packages/tracer/tests/unit/Tracer.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type CaptureAsyncFuncMock = jest.SpyInstance<
2020
[
2121
name: string,
2222
fcn: (subsegment?: Subsegment) => unknown,
23-
parent?: Segment | Subsegment
23+
parent?: Segment | Subsegment,
2424
]
2525
>;
2626
const createCaptureAsyncFuncMock = function (

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"incremental": true,
44
"composite": true,
5-
"target": "ES2021", // Node.js 16
5+
"target": "ES2022", // Node.js 16
66
"experimentalDecorators": true,
77
"module": "commonjs",
88
"moduleResolution": "node",

0 commit comments

Comments
 (0)