Skip to content

Commit 881138f

Browse files
committed
fix: refactor logger initialization and import structure in Router and related types
1 parent c855e53 commit 881138f

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

packages/event-handler/src/appsync-graphql/Router.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import {
22
EnvironmentVariablesService,
33
isRecord,
44
} from '@aws-lambda-powertools/commons';
5+
import type { GenericLogger } from '@aws-lambda-powertools/commons/types';
6+
import { getStringFromEnv } from '@aws-lambda-powertools/commons/utils/env';
57
import type {
6-
GenericLogger,
78
GraphQlRouteOptions,
89
GraphQlRouterOptions,
910
OnMutationHandler,
@@ -40,7 +41,10 @@ class Router {
4041

4142
public constructor(options?: GraphQlRouterOptions) {
4243
this.envService = new EnvironmentVariablesService();
43-
const alcLogLevel = this.envService.get('AWS_LAMBDA_LOG_LEVEL');
44+
const alcLogLevel = getStringFromEnv({
45+
key: 'AWS_LAMBDA_LOG_LEVEL',
46+
defaultValue: '',
47+
});
4448
this.logger = options?.logger ?? {
4549
debug: alcLogLevel === 'DEBUG' ? console.debug : () => undefined,
4650
error: console.error,

packages/event-handler/src/types/appsync-graphql.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
import type { RouteHandlerRegistry } from '../appsync-graphql/RouteHandlerRegistry.js';
2-
3-
// biome-ignore lint/suspicious/noExplicitAny: We intentionally use `any` here to represent any type of data and keep the logger is as flexible as possible.
4-
type Anything = any;
5-
6-
/**
7-
* Interface for a generic logger object.
8-
*/
9-
type GenericLogger = {
10-
trace?: (...content: Anything[]) => void;
11-
debug: (...content: Anything[]) => void;
12-
info?: (...content: Anything[]) => void;
13-
warn: (...content: Anything[]) => void;
14-
error: (...content: Anything[]) => void;
15-
};
2+
import type { Anything, GenericLogger } from './common.js';
163

174
// #region OnQuery fn
185

0 commit comments

Comments
 (0)