24 lines
591 B
TypeScript
24 lines
591 B
TypeScript
import logger, {Level, Writer, type WriterOptions} from 'log'
|
|
import {type FileSink} from 'bun'
|
|
|
|
export * as log from 'log'
|
|
export default logger
|
|
|
|
export class File extends Writer {
|
|
private readonly sink: FileSink;
|
|
|
|
public constructor(options: WriterOptions & { path: string }) {
|
|
const {path, ...rest} = options
|
|
super(rest)
|
|
this.sink = Bun.file(path).writer()
|
|
}
|
|
|
|
protected write(_level: Level, ...data: any[]) : void {
|
|
this.sink.write(data.join(" "))
|
|
}
|
|
|
|
public end() : number | Promise<number> {
|
|
return this.sink.end()
|
|
}
|
|
}
|