@poap-xyz/poap-logger
Advanced tools
Comparing version 1.0.2 to 1.1.0
{ | ||
"name": "@poap-xyz/poap-logger", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "A logger for POAP", | ||
@@ -5,0 +5,0 @@ "main": "./scr/index.js", |
@@ -1,8 +0,25 @@ | ||
import { PoapLogger } from "./types"; | ||
import { WinstonLogger } from "./winstonLogger"; | ||
import {PoapLogger, PoapLoggerType} from "./types"; | ||
import {WinstonLogger} from "./implementations/winstonLogger"; | ||
type Options = { | ||
metadata?: { [p: string]: unknown }, | ||
type?: PoapLoggerType, | ||
} | ||
export class PoapLoggerFactory { | ||
public static CreatePoapLogger() : PoapLogger { | ||
return new WinstonLogger(); | ||
private static logger: PoapLogger | undefined; | ||
private static defaultOptions: Options = { | ||
type: PoapLoggerType.WINSTON_LOGGER, | ||
} | ||
public static getLoggerInstance(options: Options): PoapLogger { | ||
const _options = { ...this.defaultOptions, ...options }; | ||
// here you have to handle more logger types | ||
if (!this.logger) { | ||
this.logger = _options.metadata ? new WinstonLogger().child({ ..._options.metadata }) : new WinstonLogger(); | ||
} | ||
return this.logger; | ||
} | ||
} |
@@ -23,2 +23,6 @@ export interface PoapLogger { | ||
export enum PoapLoggerType { | ||
WINSTON_LOGGER | ||
} | ||
export { PoapLoggerFactory } from "./poapLoggerFactory"; |
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
5039
9
98
1
1