mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
change: add global setGlobalLoggerFactory function
This commit is contained in:
committed by
Ruben Taelman
parent
db9aefe551
commit
4c534e9d5d
@@ -1,5 +1,6 @@
|
||||
import { LazyLoggerFactory } from './LazyLoggerFactory';
|
||||
import type { Logger } from './Logger';
|
||||
import type { LoggerFactory } from './LoggerFactory';
|
||||
|
||||
/**
|
||||
* Gets a logger instance for the given class instance.
|
||||
@@ -19,8 +20,16 @@ import type { Logger } from './Logger';
|
||||
*
|
||||
* @param loggable - A class instance or a class string name.
|
||||
*/
|
||||
export const getLoggerFor = (loggable: string | Instance): Logger => LazyLoggerFactory.getInstance()
|
||||
.createLogger(typeof loggable === 'string' ? loggable : loggable.constructor.name);
|
||||
export const getLoggerFor = (loggable: string | Instance): Logger => LazyLoggerFactory
|
||||
.getInstance().createLogger(typeof loggable === 'string' ? loggable : loggable.constructor.name);
|
||||
|
||||
/**
|
||||
* Sets the global logger factory.
|
||||
* This will cause all loggers created by {@link getLoggerFor} to be delegated to a logger from the given factory.
|
||||
* @param loggerFactory - A logger factory, of undefined for unsetting it.
|
||||
*/
|
||||
export const setGlobalLoggerFactory = (loggerFactory: LoggerFactory | undefined): void => LazyLoggerFactory
|
||||
.getInstance().setLoggerFactory(loggerFactory);
|
||||
|
||||
/**
|
||||
* Helper interface to identify class instances.
|
||||
|
||||
Reference in New Issue
Block a user