implement lib
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
export {Console} from 'writer/console'
|
||||
export {File} from 'writer/file'
|
||||
export {Counter} from 'writer/counter'
|
||||
|
||||
import {Level, type WriterOptions} from 'types'
|
||||
|
||||
export abstract class Writer {
|
||||
protected readonly _options: WriterOptions;
|
||||
protected constructor(options: WriterOptions) {
|
||||
this._options = options
|
||||
}
|
||||
|
||||
public log(level: Level, ...data: any[]) : void {
|
||||
if (level < this.options.minLevel) return
|
||||
this.write(level, ...data)
|
||||
}
|
||||
protected abstract write(level: Level, ...data: any[]) : void;
|
||||
|
||||
public get options() : WriterOptions {
|
||||
return this._options
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user