Compare commits
1 Commits
v1.0.1-bet
...
v1.0.1-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5b9bc7b69 |
15
logger.ts
15
logger.ts
@@ -177,14 +177,19 @@ export class LoggerComponent implements ILoggerComponent {
|
||||
}
|
||||
}
|
||||
|
||||
// Export a singleton instance for convenience
|
||||
let defaultLogger: LoggerComponent | null = null;
|
||||
// Cache logger instances by context to avoid recreating them
|
||||
const loggerCache = new Map<string, LoggerComponent>();
|
||||
|
||||
export function getLogger(context = 'main'): ILoggerComponent {
|
||||
if (!defaultLogger) {
|
||||
defaultLogger = new LoggerComponent(context);
|
||||
// Return cached logger for this context if it exists
|
||||
if (loggerCache.has(context)) {
|
||||
return loggerCache.get(context)!;
|
||||
}
|
||||
return defaultLogger;
|
||||
|
||||
// Create new logger for this context
|
||||
const newLogger = new LoggerComponent(context);
|
||||
loggerCache.set(context, newLogger);
|
||||
return newLogger;
|
||||
}
|
||||
|
||||
// Export default instance
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "@metatrom/logger",
|
||||
"version": "1.0.1-beta.2",
|
||||
"version": "1.0.1-beta.3",
|
||||
"main": "index.ts",
|
||||
"type": "module",
|
||||
"metatrom": {
|
||||
"ior": "com.metatrom.universal-components.logger@1.0.1-beta.2",
|
||||
"ior": "com.metatrom.universal-components.logger@1.0.1-beta.3",
|
||||
"capabilities": {
|
||||
"p2p": false,
|
||||
"contracts": false,
|
||||
|
||||
Reference in New Issue
Block a user