QuickieLog/quickielog/index.js

16 lines
441 B
JavaScript
Raw Permalink Normal View History

2025-01-01 23:11:32 +00:00
"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;