MCPcopy
hub / github.com/authts/oidc-client-ts / Logger

Class Logger

src/utils/Logger.ts:67–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65 * @public
66 */
67export class Logger {
68 private _method?: string;
69 public constructor(private _name: string) {}
70
71 /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
72 public debug(...args: unknown[]): void {
73 if (level >= Log.DEBUG) {
74 logger.debug(Logger._format(this._name, this._method), ...args);
75 }
76 }
77 public info(...args: unknown[]): void {
78 if (level >= Log.INFO) {
79 logger.info(Logger._format(this._name, this._method), ...args);
80 }
81 }
82 public warn(...args: unknown[]): void {
83 if (level >= Log.WARN) {
84 logger.warn(Logger._format(this._name, this._method), ...args);
85 }
86 }
87 public error(...args: unknown[]): void {
88 if (level >= Log.ERROR) {
89 logger.error(Logger._format(this._name, this._method), ...args);
90 }
91 }
92 /* eslint-enable @typescript-eslint/no-unsafe-enum-comparison */
93
94 public throw(err: Error): never {
95 this.error(err);
96 throw err;
97 }
98
99 public create(method: string): Logger {
100 const methodLogger: Logger = Object.create(this);
101 methodLogger._method = method;
102 methodLogger.debug("begin");
103 return methodLogger;
104 }
105
106 public static createStatic(name: string, staticMethod: string): Logger {
107 const staticLogger = new Logger(`${name}.${staticMethod}`);
108 staticLogger.debug("begin");
109 return staticLogger;
110 }
111
112 private static _format(name: string, method?: string) {
113 const prefix = `[${name}]`;
114 return method ? `${prefix} ${method}:` : prefix;
115 }
116
117 /* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
118 // helpers for static class methods
119 public static debug(name: string, ...args: unknown[]): void {
120 if (level >= Log.DEBUG) {
121 logger.debug(Logger._format(name), ...args);
122 }
123 }
124 public static info(name: string, ...args: unknown[]): void {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…