UNPKG

541 BJavaScriptView Raw
1if (global.consola) {
2 module.exports = global.consola
3} else {
4 const env = require('std-env')
5 const { Consola, BasicReporter, FancyReporter } = require('./dist/consola.js')
6
7 // Log level
8 let level = env.debug ? 4 : 3
9 if (process.env['CONSOLA_LEVEL']) {
10 level = parseInt(process.env['CONSOLA_LEVEL']) || level
11 }
12
13 // Create new consola instance
14 module.exports = global.consola = new Consola({
15 level,
16 reporters: [
17 (env.ci || env.test)
18 ? new BasicReporter()
19 : new FancyReporter()
20 ]
21 })
22}