aboutsummaryrefslogtreecommitdiff
path: root/lib/logging.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/logging.js')
-rw-r--r--lib/logging.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/logging.js b/lib/logging.js
new file mode 100644
index 0000000..bca6eb6
--- /dev/null
+++ b/lib/logging.js
@@ -0,0 +1,35 @@
+const log4js = require('log4js')
+
+module.exports = {
+ configure(verbose) {
+ const categories = {
+ default: {
+ appenders: ['stdout-filter'],
+ level: 'trace'
+ }
+ }
+ const appenders = {
+ stdout: {
+ type: 'stdout',
+ level: 'warn'
+ },
+ 'stdout-filter': {
+ type: 'logLevelFilter',
+ appender: 'stdout',
+ level: verbose ? 'debug' : 'warn'
+ }
+ }
+ log4js.configure({
+ appenders,
+ categories
+ })
+ },
+
+ getLogger(...args) {
+ return log4js.getLogger(...args)
+ },
+
+ shutdown(cb) {
+ log4js.shutdown(cb)
+ }
+}