Skip to content

Commit 142066c

Browse files
committed
fix(logging): debug() should not use console.trace()
Problem: The console.trace() docstring says: Prints to `stderr` the string 'Trace :', followed by the util.format formatted message and stack trace to the current position in the code. But that is not useful/desirable for our codebase; we want logger.debug() to write to the browser console (if available). Solution: Use console.debug() instead of console.trace().
1 parent f9f9d7b commit 142066c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/shared/logger/logger.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ export class NullLogger implements Logger {
100100
}
101101

102102
/**
103-
* Fallback to console.log() if getLogger() is requested before logging is fully initialized.
103+
* Fallback used if {@link getLogger()} is requested before logging is fully initialized.
104104
*/
105105
export class ConsoleLogger implements Logger {
106106
public setLogLevel(logLevel: LogLevel) {}
107107
public logLevelEnabled(logLevel: LogLevel): boolean {
108108
return false
109109
}
110110
public debug(message: string | Error, ...meta: any[]): number {
111-
console.trace(message, ...meta)
111+
console.debug(message, ...meta)
112112
return 0
113113
}
114114
public verbose(message: string | Error, ...meta: any[]): number {
@@ -123,6 +123,7 @@ export class ConsoleLogger implements Logger {
123123
console.warn(message, ...meta)
124124
return 0
125125
}
126+
/** Note: In nodejs this prints to `stderr` (see {@link Console.error}). */
126127
public error(message: string | Error, ...meta: any[]): number {
127128
console.error(message, ...meta)
128129
return 0

0 commit comments

Comments
 (0)