init File Logger
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
bun.lockb
|
||||
package-lock.json
|
||||
node_modules/
|
||||
.idea/
|
||||
._*
|
||||
.DS_Store
|
||||
@@ -0,0 +1,23 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "logger-file",
|
||||
"description": "Log writer to file",
|
||||
"version": "1.0.0",
|
||||
"author": "Pascal Perrenoud <pascal@pband.ch>",
|
||||
"module": "index.ts",
|
||||
"type": "module",
|
||||
"files": ["index.ts"],
|
||||
"dependencies": {
|
||||
"log": "git+git@git.pband.ch:typescript/log"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "^1.1.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
// Enable latest features
|
||||
"lib": ["ESNext","dom"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
|
||||
// Bundler mode
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noPropertyAccessFromIndexSignature": false
|
||||
},
|
||||
|
||||
"include": [
|
||||
"index.ts",
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user