refactor(logging): separate console and debug logger classes
- Preserve TraceLogger console formatting and add DebugLogger with DEBUG namespace output. - Select the logger through LOG_MODE and route application call sites through the factory. - Cover factory selection, console formatting, debug output and auth-log redaction.
This commit is contained in:
1 parent
ceed27ad9e
commit
7235abdcef
16 files changed
+146
-142
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import { ConsoleLoggerOptions } from "@nestjs/common";
|
||||
import { LogMode } from "../config/app.config";
|
||||
import { DebugLogger } from "./debug-logger";
|
||||
import { TraceLogger } from "./trace-logger";
|
||||
|
||||
/** Select the application's logger implementation at the configuration boundary. */
|
||||
export function createAppLogger(
|
||||
context?: string,
|
||||
options?: ConsoleLoggerOptions,
|
||||
) {
|
||||
return process.env.LOG_MODE === LogMode.Debug
|
||||
? new DebugLogger(context, options)
|
||||
: new TraceLogger(context, options);
|
||||
}
|
||||
Reference in new issue
Block a user