Skip to content

Commit 729bebd

Browse files
committed
Refactor LoggerFactory from static class to module functions
- Replace LoggerFactory class with getLogger and clearLoggers functions - Fix noStaticOnlyClass lint error - Maintain same functionality with simpler API
1 parent 7e52c13 commit 729bebd

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

src/utils/command/logger.mts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -146,28 +146,26 @@ export function createDebugLogger(namespace: string): (...args: any[]) => void {
146146
}
147147

148148
/**
149-
* Logger factory for creating consistent command loggers
149+
* Logger factory for creating consistent command loggers.
150150
*/
151-
export class LoggerFactory {
152-
private static instances = new Map<string, CommandLogger>()
151+
const instances = new Map<string, CommandLogger>()
153152

154-
/**
155-
* Get or create a command logger
156-
*
157-
* @param commandName - The command name
158-
* @returns A cached or new command logger
159-
*/
160-
static getLogger(commandName: string): CommandLogger {
161-
if (!LoggerFactory.instances.has(commandName)) {
162-
LoggerFactory.instances.set(commandName, createCommandLogger(commandName))
163-
}
164-
return LoggerFactory.instances.get(commandName)!
153+
/**
154+
* Get or create a command logger.
155+
*
156+
* @param commandName - The command name
157+
* @returns A cached or new command logger
158+
*/
159+
export function getLogger(commandName: string): CommandLogger {
160+
if (!instances.has(commandName)) {
161+
instances.set(commandName, createCommandLogger(commandName))
165162
}
163+
return instances.get(commandName)!
164+
}
166165

167-
/**
168-
* Clear all cached loggers
169-
*/
170-
static clear(): void {
171-
LoggerFactory.instances.clear()
172-
}
166+
/**
167+
* Clear all cached loggers.
168+
*/
169+
export function clearLoggers(): void {
170+
instances.clear()
173171
}

0 commit comments

Comments
 (0)