Skip to content

Commit 4112a0e

Browse files
committed
feat: adding VerboseLogger to avoid restrictions on DefaultLogger
Signed-off-by: Kevin Long <[email protected]>
1 parent 26dbbaf commit 4112a0e

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

packages/shared/src/hooks/logging-hook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { BaseHook } from './hook';
33
import type { BeforeHookContext, HookContext, HookHints } from './hooks';
44
import type { FlagValue, EvaluationDetails } from '../evaluation';
55

6-
import { DefaultLogger, SafeLogger } from '../logger';
6+
import { VerboseLogger, SafeLogger } from '../logger';
77

88
type LoggerPayload = Record<string, unknown>;
99

@@ -20,7 +20,7 @@ const VALUE_KEY = 'value';
2020

2121
export class LoggingHook implements BaseHook {
2222
readonly includeEvaluationContext: boolean = false;
23-
readonly logger = new SafeLogger(new DefaultLogger());
23+
readonly logger = new SafeLogger(new VerboseLogger());
2424

2525
constructor(includeEvaluationContext: boolean = false) {
2626
this.includeEvaluationContext = !!includeEvaluationContext;

packages/shared/src/logger/default-logger.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ export class DefaultLogger implements Logger {
1111
console.warn(...args);
1212
}
1313

14-
info(...args: unknown[]): void {
15-
console.info(...args);
16-
}
14+
info(): void {}
1715

18-
debug(...args: unknown[]): void {
19-
console.debug(...args);
20-
}
16+
debug(): void {}
2117
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './logger';
22
export * from './default-logger';
33
export * from './safe-logger';
4+
export * from './verbose-logger';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { Logger } from './logger';
2+
3+
export class VerboseLogger implements Logger {
4+
error(...args: unknown[]): void {
5+
console.error(...args);
6+
}
7+
8+
warn(...args: unknown[]): void {
9+
console.warn(...args);
10+
}
11+
12+
info(...args: unknown[]): void {
13+
console.info(...args);
14+
}
15+
16+
debug(...args: unknown[]): void {
17+
console.debug(...args);
18+
}
19+
}

0 commit comments

Comments
 (0)