forked from nuxt-community/legacy-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging.js
32 lines (27 loc) · 793 Bytes
/
logging.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
28
29
30
31
32
if (process.env.NODE_ENV === 'production') {
const log = () => () => null
const error = () => () => null
module.exports = { log, error }
} else {
const Debug = require('debug')
let instances = {}
const log = (plugin_name) => {
if (!instances['log_' + plugin_name]) {
const log = Debug('plugin:' + plugin_name)
log.enabled = true
log.color = 5
instances['log_' + plugin_name] = log
}
return instances['log_' + plugin_name]
}
const error = (plugin_name) => {
if (!instances['err_' + plugin_name]) {
const error = Debug('plugin:' + plugin_name)
error.enabled = true
error.color = 1
instances['err_' + plugin_name] = error
}
return instances['err_' + plugin_name]
}
module.exports = { log, error }
}