1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
ocean.js/src/utils/Logger.ts
Bogdan Fazakas faa7de3601
Feature/Add order util method (#1759)
* added order  helper method using contracts calls

* fixes consume fees  & lint

* cleanup

* update order helper method to be more generic

* fix all warnings
2023-08-25 17:33:06 +03:00

48 lines
1020 B
TypeScript

/* eslint-disable no-unused-vars */
export enum LogLevel {
None = -1,
Error = 0,
Warn = 1,
Log = 2,
Verbose = 3
}
/* eslint-enable no-unused-vars */
export class Logger {
constructor(private logLevel?: LogLevel) {
this.logLevel = logLevel || LogLevel.Error
}
public setLevel(logLevel: LogLevel): void {
this.logLevel = logLevel
}
public bypass(...args: any[]): void {
this.dispatch('log', -Infinity as any, ...args)
}
public debug(...args: any[]): void {
this.dispatch('debug', LogLevel.Verbose, ...args)
}
public log(...args: any[]): void {
this.dispatch('log', LogLevel.Log, ...args)
}
public warn(...args: any[]): void {
this.dispatch('warn', LogLevel.Warn, ...args)
}
public error(...args: any[]): void {
this.dispatch('error', LogLevel.Error, ...args)
}
private dispatch(verb: string, level: LogLevel, ...args: any[]) {
if (this.logLevel >= level) {
console[verb](...args)
}
}
}
export const LoggerInstance = new Logger()