-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
27 lines (24 loc) · 804 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const Logger = require('./lib/logger')
const DEFAULT_CONFIG = [{
type: 'console',
}]
module.exports = function build(_opt) {
const opt = _opt || DEFAULT_CONFIG
if (opt instanceof Array === false) {
throw new Error('build config must be a Array')
}
const logger = new Logger()
for (let i = 0; i < opt.length; ++i) {
try {
// eslint-disable-next-line global-require, import/no-dynamic-require
const Appender = require(`./lib/drivers/${opt[i].type}`)
const appender = new Appender(opt[i])
logger.appenders.push(appender)
} catch (e) {
// eslint-disable-next-line no-console
console.error('EZlogs ERROR: ', e)
}
}
return logger
}
module.exports.EZLogs = module.exports