feat(logging): Centralize debug logging with a dedicated utility (#11417)

This commit is contained in:
Abhi
2025-10-17 18:00:23 -04:00
committed by GitHub
parent 0b20f88fc0
commit 9b9ab60985
4 changed files with 127 additions and 9 deletions

View File

@@ -0,0 +1,37 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* A simple, centralized logger for developer-facing debug messages.
*
* WHY USE THIS?
* - It makes the INTENT of the log clear (it's for developers, not users).
* - It provides a single point of control for debug logging behavior.
* - We can lint against direct `console.*` usage to enforce this pattern.
*
* HOW IT WORKS:
* This is a thin wrapper around the native `console` object. The `ConsolePatcher`
* will intercept these calls and route them to the debug drawer UI.
*/
class DebugLogger {
log(...args: unknown[]): void {
console.log(...args);
}
warn(...args: unknown[]): void {
console.warn(...args);
}
error(...args: unknown[]): void {
console.error(...args);
}
debug(...args: unknown[]): void {
console.debug(...args);
}
}
export const debugLogger = new DebugLogger();