Skip to content

Commit

Permalink
feat: add logger
Browse files Browse the repository at this point in the history
- use log4js for logger
  • Loading branch information
Chinlinlee committed Mar 1, 2022
1 parent 56fcfca commit ce60bf2
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 18 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ models/mongodb/FHIRDataTypesSchema-New
config/config.js

#ignore apidoc comment files
docs/apidoc/apidoc-sources
docs/apidoc/apidoc-sources

#ignore log files
/log
/pm2log
38 changes: 38 additions & 0 deletions config/log4js.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"appenders": {
"burni-info": {
"type": "file",
"filename": "log/burni-info.log",
"maxLogSize": 10485760,
"numBackups": 3
},
"burni-error": {
"type": "file",
"filename": "log/errors.log"
},
"errors": {
"type": "logLevelFilter",
"level": "ERROR",
"appender": "burni-error"
},
"infos": {
"type": "logLevelFilter",
"level": "INFO",
"maxLevel": "INFO",
"appender": "burni-info"
},
"console": {
"type": "console"
}
},
"categories": {
"default": {
"appenders": [
"infos",
"errors",
"console"
],
"level": "DEBUG"
}
}
}
168 changes: 151 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"js-beautify": "^1.13.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.21",
"log4js": "^6.4.1",
"mkdirp": "^1.0.4",
"moment": "^2.24.0",
"moment-timezone": "^0.5.33",
Expand Down
6 changes: 6 additions & 0 deletions utils/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const path = require('path');
const { configure, getLogger } = require('log4js');
configure(path.join(__dirname, "../config/log4js.json"));
let burniLog = getLogger("burni");

module.exports.logger = burniLog;

0 comments on commit ce60bf2

Please sign in to comment.