Add quickielog/index.js
This commit is contained in:
parent
44361edaae
commit
7852fafa15
1 changed files with 16 additions and 0 deletions
16
quickielog/index.js
Normal file
16
quickielog/index.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
class Logger {
|
||||
constructor(app_name, use_json = false) {
|
||||
this.app_name = app_name
|
||||
this.use_json = use_json
|
||||
}
|
||||
}
|
||||
function log(logger, level, msg) {
|
||||
if (logger.use_json) {
|
||||
console.log(`{\"app\": \"${logger.app_name}\",\"level\": \"${level}\",\"message\": \"${msg}\"}`)
|
||||
} else {
|
||||
console.log(`${logger.app_name} [${level}]: ${msg}`)
|
||||
}
|
||||
}
|
||||
exports.log = log;
|
||||
exports.Logger = Logger;
|
Loading…
Reference in a new issue