init Console Logger
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
bun.lockb
|
||||
package-lock.json
|
||||
node_modules/
|
||||
.idea/
|
||||
._*
|
||||
.DS_Store
|
||||
@@ -0,0 +1,20 @@
|
||||
import logger, {Writer, Level} from 'log'
|
||||
|
||||
export * as log from 'log'
|
||||
export default logger
|
||||
|
||||
export class Console extends Writer {
|
||||
protected write(level: Level, ...data: any[]) : void {
|
||||
Console.get_logger(level)(...data)
|
||||
}
|
||||
|
||||
private static get_logger(level: Level) {
|
||||
switch (level) {
|
||||
case Level.DEBUG: return console.debug
|
||||
case Level.TRACE: return console.debug
|
||||
case Level.INFO: return console.log
|
||||
case Level.WARNING: return console.warn
|
||||
case Level.ERROR: return console.error
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "logger-console",
|
||||
"description": "Logger to console, for client and server",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
|
||||
// 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