2021-08-29 11:58:11 -07:00
|
|
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
|
|
import { ILogger, LogTypes } from './Interfaces';
|
2021-05-01 20:43:01 -07:00
|
|
|
|
|
|
|
let logger: ILogger | undefined;
|
|
|
|
|
|
|
|
export function init(loggerInstance: ILogger) {
|
|
|
|
logger = loggerInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getInstance(): ILogger {
|
|
|
|
if (logger === undefined) {
|
|
|
|
throw new Error('LoggerProxy not initialized');
|
|
|
|
}
|
|
|
|
|
|
|
|
return logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function log(type: LogTypes, message: string, meta: object = {}) {
|
|
|
|
getInstance().log(type, message, meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convenience methods below
|
|
|
|
|
|
|
|
export function debug(message: string, meta: object = {}) {
|
|
|
|
getInstance().log('debug', message, meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function info(message: string, meta: object = {}) {
|
|
|
|
getInstance().log('info', message, meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function error(message: string, meta: object = {}) {
|
|
|
|
getInstance().log('error', message, meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function verbose(message: string, meta: object = {}) {
|
|
|
|
getInstance().log('verbose', message, meta);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function warn(message: string, meta: object = {}) {
|
|
|
|
getInstance().log('warn', message, meta);
|
|
|
|
}
|