11cb0ef41Sopenharmony_ci'use strict' 21cb0ef41Sopenharmony_civar Progress = require('are-we-there-yet') 31cb0ef41Sopenharmony_civar Gauge = require('gauge') 41cb0ef41Sopenharmony_civar EE = require('events').EventEmitter 51cb0ef41Sopenharmony_civar log = exports = module.exports = new EE() 61cb0ef41Sopenharmony_civar util = require('util') 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_civar setBlocking = require('set-blocking') 91cb0ef41Sopenharmony_civar consoleControl = require('console-control-strings') 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cisetBlocking(true) 121cb0ef41Sopenharmony_civar stream = process.stderr 131cb0ef41Sopenharmony_ciObject.defineProperty(log, 'stream', { 141cb0ef41Sopenharmony_ci set: function (newStream) { 151cb0ef41Sopenharmony_ci stream = newStream 161cb0ef41Sopenharmony_ci if (this.gauge) { 171cb0ef41Sopenharmony_ci this.gauge.setWriteTo(stream, stream) 181cb0ef41Sopenharmony_ci } 191cb0ef41Sopenharmony_ci }, 201cb0ef41Sopenharmony_ci get: function () { 211cb0ef41Sopenharmony_ci return stream 221cb0ef41Sopenharmony_ci }, 231cb0ef41Sopenharmony_ci}) 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci// by default, decide based on tty-ness. 261cb0ef41Sopenharmony_civar colorEnabled 271cb0ef41Sopenharmony_cilog.useColor = function () { 281cb0ef41Sopenharmony_ci return colorEnabled != null ? colorEnabled : stream.isTTY 291cb0ef41Sopenharmony_ci} 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_cilog.enableColor = function () { 321cb0ef41Sopenharmony_ci colorEnabled = true 331cb0ef41Sopenharmony_ci this.gauge.setTheme({ hasColor: colorEnabled, hasUnicode: unicodeEnabled }) 341cb0ef41Sopenharmony_ci} 351cb0ef41Sopenharmony_cilog.disableColor = function () { 361cb0ef41Sopenharmony_ci colorEnabled = false 371cb0ef41Sopenharmony_ci this.gauge.setTheme({ hasColor: colorEnabled, hasUnicode: unicodeEnabled }) 381cb0ef41Sopenharmony_ci} 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci// default level 411cb0ef41Sopenharmony_cilog.level = 'info' 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_cilog.gauge = new Gauge(stream, { 441cb0ef41Sopenharmony_ci enabled: false, // no progress bars unless asked 451cb0ef41Sopenharmony_ci theme: { hasColor: log.useColor() }, 461cb0ef41Sopenharmony_ci template: [ 471cb0ef41Sopenharmony_ci { type: 'progressbar', length: 20 }, 481cb0ef41Sopenharmony_ci { type: 'activityIndicator', kerning: 1, length: 1 }, 491cb0ef41Sopenharmony_ci { type: 'section', default: '' }, 501cb0ef41Sopenharmony_ci ':', 511cb0ef41Sopenharmony_ci { type: 'logline', kerning: 1, default: '' }, 521cb0ef41Sopenharmony_ci ], 531cb0ef41Sopenharmony_ci}) 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_cilog.tracker = new Progress.TrackerGroup() 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci// we track this separately as we may need to temporarily disable the 581cb0ef41Sopenharmony_ci// display of the status bar for our own loggy purposes. 591cb0ef41Sopenharmony_cilog.progressEnabled = log.gauge.isEnabled() 601cb0ef41Sopenharmony_ci 611cb0ef41Sopenharmony_civar unicodeEnabled 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_cilog.enableUnicode = function () { 641cb0ef41Sopenharmony_ci unicodeEnabled = true 651cb0ef41Sopenharmony_ci this.gauge.setTheme({ hasColor: this.useColor(), hasUnicode: unicodeEnabled }) 661cb0ef41Sopenharmony_ci} 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_cilog.disableUnicode = function () { 691cb0ef41Sopenharmony_ci unicodeEnabled = false 701cb0ef41Sopenharmony_ci this.gauge.setTheme({ hasColor: this.useColor(), hasUnicode: unicodeEnabled }) 711cb0ef41Sopenharmony_ci} 721cb0ef41Sopenharmony_ci 731cb0ef41Sopenharmony_cilog.setGaugeThemeset = function (themes) { 741cb0ef41Sopenharmony_ci this.gauge.setThemeset(themes) 751cb0ef41Sopenharmony_ci} 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_cilog.setGaugeTemplate = function (template) { 781cb0ef41Sopenharmony_ci this.gauge.setTemplate(template) 791cb0ef41Sopenharmony_ci} 801cb0ef41Sopenharmony_ci 811cb0ef41Sopenharmony_cilog.enableProgress = function () { 821cb0ef41Sopenharmony_ci if (this.progressEnabled || this._paused) { 831cb0ef41Sopenharmony_ci return 841cb0ef41Sopenharmony_ci } 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci this.progressEnabled = true 871cb0ef41Sopenharmony_ci this.tracker.on('change', this.showProgress) 881cb0ef41Sopenharmony_ci this.gauge.enable() 891cb0ef41Sopenharmony_ci} 901cb0ef41Sopenharmony_ci 911cb0ef41Sopenharmony_cilog.disableProgress = function () { 921cb0ef41Sopenharmony_ci if (!this.progressEnabled) { 931cb0ef41Sopenharmony_ci return 941cb0ef41Sopenharmony_ci } 951cb0ef41Sopenharmony_ci this.progressEnabled = false 961cb0ef41Sopenharmony_ci this.tracker.removeListener('change', this.showProgress) 971cb0ef41Sopenharmony_ci this.gauge.disable() 981cb0ef41Sopenharmony_ci} 991cb0ef41Sopenharmony_ci 1001cb0ef41Sopenharmony_civar trackerConstructors = ['newGroup', 'newItem', 'newStream'] 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_civar mixinLog = function (tracker) { 1031cb0ef41Sopenharmony_ci // mixin the public methods from log into the tracker 1041cb0ef41Sopenharmony_ci // (except: conflicts and one's we handle specially) 1051cb0ef41Sopenharmony_ci Object.keys(log).forEach(function (P) { 1061cb0ef41Sopenharmony_ci if (P[0] === '_') { 1071cb0ef41Sopenharmony_ci return 1081cb0ef41Sopenharmony_ci } 1091cb0ef41Sopenharmony_ci 1101cb0ef41Sopenharmony_ci if (trackerConstructors.filter(function (C) { 1111cb0ef41Sopenharmony_ci return C === P 1121cb0ef41Sopenharmony_ci }).length) { 1131cb0ef41Sopenharmony_ci return 1141cb0ef41Sopenharmony_ci } 1151cb0ef41Sopenharmony_ci 1161cb0ef41Sopenharmony_ci if (tracker[P]) { 1171cb0ef41Sopenharmony_ci return 1181cb0ef41Sopenharmony_ci } 1191cb0ef41Sopenharmony_ci 1201cb0ef41Sopenharmony_ci if (typeof log[P] !== 'function') { 1211cb0ef41Sopenharmony_ci return 1221cb0ef41Sopenharmony_ci } 1231cb0ef41Sopenharmony_ci 1241cb0ef41Sopenharmony_ci var func = log[P] 1251cb0ef41Sopenharmony_ci tracker[P] = function () { 1261cb0ef41Sopenharmony_ci return func.apply(log, arguments) 1271cb0ef41Sopenharmony_ci } 1281cb0ef41Sopenharmony_ci }) 1291cb0ef41Sopenharmony_ci // if the new tracker is a group, make sure any subtrackers get 1301cb0ef41Sopenharmony_ci // mixed in too 1311cb0ef41Sopenharmony_ci if (tracker instanceof Progress.TrackerGroup) { 1321cb0ef41Sopenharmony_ci trackerConstructors.forEach(function (C) { 1331cb0ef41Sopenharmony_ci var func = tracker[C] 1341cb0ef41Sopenharmony_ci tracker[C] = function () { 1351cb0ef41Sopenharmony_ci return mixinLog(func.apply(tracker, arguments)) 1361cb0ef41Sopenharmony_ci } 1371cb0ef41Sopenharmony_ci }) 1381cb0ef41Sopenharmony_ci } 1391cb0ef41Sopenharmony_ci return tracker 1401cb0ef41Sopenharmony_ci} 1411cb0ef41Sopenharmony_ci 1421cb0ef41Sopenharmony_ci// Add tracker constructors to the top level log object 1431cb0ef41Sopenharmony_citrackerConstructors.forEach(function (C) { 1441cb0ef41Sopenharmony_ci log[C] = function () { 1451cb0ef41Sopenharmony_ci return mixinLog(this.tracker[C].apply(this.tracker, arguments)) 1461cb0ef41Sopenharmony_ci } 1471cb0ef41Sopenharmony_ci}) 1481cb0ef41Sopenharmony_ci 1491cb0ef41Sopenharmony_cilog.clearProgress = function (cb) { 1501cb0ef41Sopenharmony_ci if (!this.progressEnabled) { 1511cb0ef41Sopenharmony_ci return cb && process.nextTick(cb) 1521cb0ef41Sopenharmony_ci } 1531cb0ef41Sopenharmony_ci 1541cb0ef41Sopenharmony_ci this.gauge.hide(cb) 1551cb0ef41Sopenharmony_ci} 1561cb0ef41Sopenharmony_ci 1571cb0ef41Sopenharmony_cilog.showProgress = function (name, completed) { 1581cb0ef41Sopenharmony_ci if (!this.progressEnabled) { 1591cb0ef41Sopenharmony_ci return 1601cb0ef41Sopenharmony_ci } 1611cb0ef41Sopenharmony_ci 1621cb0ef41Sopenharmony_ci var values = {} 1631cb0ef41Sopenharmony_ci if (name) { 1641cb0ef41Sopenharmony_ci values.section = name 1651cb0ef41Sopenharmony_ci } 1661cb0ef41Sopenharmony_ci 1671cb0ef41Sopenharmony_ci var last = log.record[log.record.length - 1] 1681cb0ef41Sopenharmony_ci if (last) { 1691cb0ef41Sopenharmony_ci values.subsection = last.prefix 1701cb0ef41Sopenharmony_ci var disp = log.disp[last.level] || last.level 1711cb0ef41Sopenharmony_ci var logline = this._format(disp, log.style[last.level]) 1721cb0ef41Sopenharmony_ci if (last.prefix) { 1731cb0ef41Sopenharmony_ci logline += ' ' + this._format(last.prefix, this.prefixStyle) 1741cb0ef41Sopenharmony_ci } 1751cb0ef41Sopenharmony_ci 1761cb0ef41Sopenharmony_ci logline += ' ' + last.message.split(/\r?\n/)[0] 1771cb0ef41Sopenharmony_ci values.logline = logline 1781cb0ef41Sopenharmony_ci } 1791cb0ef41Sopenharmony_ci values.completed = completed || this.tracker.completed() 1801cb0ef41Sopenharmony_ci this.gauge.show(values) 1811cb0ef41Sopenharmony_ci}.bind(log) // bind for use in tracker's on-change listener 1821cb0ef41Sopenharmony_ci 1831cb0ef41Sopenharmony_ci// temporarily stop emitting, but don't drop 1841cb0ef41Sopenharmony_cilog.pause = function () { 1851cb0ef41Sopenharmony_ci this._paused = true 1861cb0ef41Sopenharmony_ci if (this.progressEnabled) { 1871cb0ef41Sopenharmony_ci this.gauge.disable() 1881cb0ef41Sopenharmony_ci } 1891cb0ef41Sopenharmony_ci} 1901cb0ef41Sopenharmony_ci 1911cb0ef41Sopenharmony_cilog.resume = function () { 1921cb0ef41Sopenharmony_ci if (!this._paused) { 1931cb0ef41Sopenharmony_ci return 1941cb0ef41Sopenharmony_ci } 1951cb0ef41Sopenharmony_ci 1961cb0ef41Sopenharmony_ci this._paused = false 1971cb0ef41Sopenharmony_ci 1981cb0ef41Sopenharmony_ci var b = this._buffer 1991cb0ef41Sopenharmony_ci this._buffer = [] 2001cb0ef41Sopenharmony_ci b.forEach(function (m) { 2011cb0ef41Sopenharmony_ci this.emitLog(m) 2021cb0ef41Sopenharmony_ci }, this) 2031cb0ef41Sopenharmony_ci if (this.progressEnabled) { 2041cb0ef41Sopenharmony_ci this.gauge.enable() 2051cb0ef41Sopenharmony_ci } 2061cb0ef41Sopenharmony_ci} 2071cb0ef41Sopenharmony_ci 2081cb0ef41Sopenharmony_cilog._buffer = [] 2091cb0ef41Sopenharmony_ci 2101cb0ef41Sopenharmony_civar id = 0 2111cb0ef41Sopenharmony_cilog.record = [] 2121cb0ef41Sopenharmony_cilog.maxRecordSize = 10000 2131cb0ef41Sopenharmony_cilog.log = function (lvl, prefix, message) { 2141cb0ef41Sopenharmony_ci var l = this.levels[lvl] 2151cb0ef41Sopenharmony_ci if (l === undefined) { 2161cb0ef41Sopenharmony_ci return this.emit('error', new Error(util.format( 2171cb0ef41Sopenharmony_ci 'Undefined log level: %j', lvl))) 2181cb0ef41Sopenharmony_ci } 2191cb0ef41Sopenharmony_ci 2201cb0ef41Sopenharmony_ci var a = new Array(arguments.length - 2) 2211cb0ef41Sopenharmony_ci var stack = null 2221cb0ef41Sopenharmony_ci for (var i = 2; i < arguments.length; i++) { 2231cb0ef41Sopenharmony_ci var arg = a[i - 2] = arguments[i] 2241cb0ef41Sopenharmony_ci 2251cb0ef41Sopenharmony_ci // resolve stack traces to a plain string. 2261cb0ef41Sopenharmony_ci if (typeof arg === 'object' && arg instanceof Error && arg.stack) { 2271cb0ef41Sopenharmony_ci Object.defineProperty(arg, 'stack', { 2281cb0ef41Sopenharmony_ci value: stack = arg.stack + '', 2291cb0ef41Sopenharmony_ci enumerable: true, 2301cb0ef41Sopenharmony_ci writable: true, 2311cb0ef41Sopenharmony_ci }) 2321cb0ef41Sopenharmony_ci } 2331cb0ef41Sopenharmony_ci } 2341cb0ef41Sopenharmony_ci if (stack) { 2351cb0ef41Sopenharmony_ci a.unshift(stack + '\n') 2361cb0ef41Sopenharmony_ci } 2371cb0ef41Sopenharmony_ci message = util.format.apply(util, a) 2381cb0ef41Sopenharmony_ci 2391cb0ef41Sopenharmony_ci var m = { 2401cb0ef41Sopenharmony_ci id: id++, 2411cb0ef41Sopenharmony_ci level: lvl, 2421cb0ef41Sopenharmony_ci prefix: String(prefix || ''), 2431cb0ef41Sopenharmony_ci message: message, 2441cb0ef41Sopenharmony_ci messageRaw: a, 2451cb0ef41Sopenharmony_ci } 2461cb0ef41Sopenharmony_ci 2471cb0ef41Sopenharmony_ci this.emit('log', m) 2481cb0ef41Sopenharmony_ci this.emit('log.' + lvl, m) 2491cb0ef41Sopenharmony_ci if (m.prefix) { 2501cb0ef41Sopenharmony_ci this.emit(m.prefix, m) 2511cb0ef41Sopenharmony_ci } 2521cb0ef41Sopenharmony_ci 2531cb0ef41Sopenharmony_ci this.record.push(m) 2541cb0ef41Sopenharmony_ci var mrs = this.maxRecordSize 2551cb0ef41Sopenharmony_ci var n = this.record.length - mrs 2561cb0ef41Sopenharmony_ci if (n > mrs / 10) { 2571cb0ef41Sopenharmony_ci var newSize = Math.floor(mrs * 0.9) 2581cb0ef41Sopenharmony_ci this.record = this.record.slice(-1 * newSize) 2591cb0ef41Sopenharmony_ci } 2601cb0ef41Sopenharmony_ci 2611cb0ef41Sopenharmony_ci this.emitLog(m) 2621cb0ef41Sopenharmony_ci}.bind(log) 2631cb0ef41Sopenharmony_ci 2641cb0ef41Sopenharmony_cilog.emitLog = function (m) { 2651cb0ef41Sopenharmony_ci if (this._paused) { 2661cb0ef41Sopenharmony_ci this._buffer.push(m) 2671cb0ef41Sopenharmony_ci return 2681cb0ef41Sopenharmony_ci } 2691cb0ef41Sopenharmony_ci if (this.progressEnabled) { 2701cb0ef41Sopenharmony_ci this.gauge.pulse(m.prefix) 2711cb0ef41Sopenharmony_ci } 2721cb0ef41Sopenharmony_ci 2731cb0ef41Sopenharmony_ci var l = this.levels[m.level] 2741cb0ef41Sopenharmony_ci if (l === undefined) { 2751cb0ef41Sopenharmony_ci return 2761cb0ef41Sopenharmony_ci } 2771cb0ef41Sopenharmony_ci 2781cb0ef41Sopenharmony_ci if (l < this.levels[this.level]) { 2791cb0ef41Sopenharmony_ci return 2801cb0ef41Sopenharmony_ci } 2811cb0ef41Sopenharmony_ci 2821cb0ef41Sopenharmony_ci if (l > 0 && !isFinite(l)) { 2831cb0ef41Sopenharmony_ci return 2841cb0ef41Sopenharmony_ci } 2851cb0ef41Sopenharmony_ci 2861cb0ef41Sopenharmony_ci // If 'disp' is null or undefined, use the lvl as a default 2871cb0ef41Sopenharmony_ci // Allows: '', 0 as valid disp 2881cb0ef41Sopenharmony_ci var disp = log.disp[m.level] != null ? log.disp[m.level] : m.level 2891cb0ef41Sopenharmony_ci this.clearProgress() 2901cb0ef41Sopenharmony_ci m.message.split(/\r?\n/).forEach(function (line) { 2911cb0ef41Sopenharmony_ci var heading = this.heading 2921cb0ef41Sopenharmony_ci if (heading) { 2931cb0ef41Sopenharmony_ci this.write(heading, this.headingStyle) 2941cb0ef41Sopenharmony_ci this.write(' ') 2951cb0ef41Sopenharmony_ci } 2961cb0ef41Sopenharmony_ci this.write(disp, log.style[m.level]) 2971cb0ef41Sopenharmony_ci var p = m.prefix || '' 2981cb0ef41Sopenharmony_ci if (p) { 2991cb0ef41Sopenharmony_ci this.write(' ') 3001cb0ef41Sopenharmony_ci } 3011cb0ef41Sopenharmony_ci 3021cb0ef41Sopenharmony_ci this.write(p, this.prefixStyle) 3031cb0ef41Sopenharmony_ci this.write(' ' + line + '\n') 3041cb0ef41Sopenharmony_ci }, this) 3051cb0ef41Sopenharmony_ci this.showProgress() 3061cb0ef41Sopenharmony_ci} 3071cb0ef41Sopenharmony_ci 3081cb0ef41Sopenharmony_cilog._format = function (msg, style) { 3091cb0ef41Sopenharmony_ci if (!stream) { 3101cb0ef41Sopenharmony_ci return 3111cb0ef41Sopenharmony_ci } 3121cb0ef41Sopenharmony_ci 3131cb0ef41Sopenharmony_ci var output = '' 3141cb0ef41Sopenharmony_ci if (this.useColor()) { 3151cb0ef41Sopenharmony_ci style = style || {} 3161cb0ef41Sopenharmony_ci var settings = [] 3171cb0ef41Sopenharmony_ci if (style.fg) { 3181cb0ef41Sopenharmony_ci settings.push(style.fg) 3191cb0ef41Sopenharmony_ci } 3201cb0ef41Sopenharmony_ci 3211cb0ef41Sopenharmony_ci if (style.bg) { 3221cb0ef41Sopenharmony_ci settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1)) 3231cb0ef41Sopenharmony_ci } 3241cb0ef41Sopenharmony_ci 3251cb0ef41Sopenharmony_ci if (style.bold) { 3261cb0ef41Sopenharmony_ci settings.push('bold') 3271cb0ef41Sopenharmony_ci } 3281cb0ef41Sopenharmony_ci 3291cb0ef41Sopenharmony_ci if (style.underline) { 3301cb0ef41Sopenharmony_ci settings.push('underline') 3311cb0ef41Sopenharmony_ci } 3321cb0ef41Sopenharmony_ci 3331cb0ef41Sopenharmony_ci if (style.inverse) { 3341cb0ef41Sopenharmony_ci settings.push('inverse') 3351cb0ef41Sopenharmony_ci } 3361cb0ef41Sopenharmony_ci 3371cb0ef41Sopenharmony_ci if (settings.length) { 3381cb0ef41Sopenharmony_ci output += consoleControl.color(settings) 3391cb0ef41Sopenharmony_ci } 3401cb0ef41Sopenharmony_ci 3411cb0ef41Sopenharmony_ci if (style.beep) { 3421cb0ef41Sopenharmony_ci output += consoleControl.beep() 3431cb0ef41Sopenharmony_ci } 3441cb0ef41Sopenharmony_ci } 3451cb0ef41Sopenharmony_ci output += msg 3461cb0ef41Sopenharmony_ci if (this.useColor()) { 3471cb0ef41Sopenharmony_ci output += consoleControl.color('reset') 3481cb0ef41Sopenharmony_ci } 3491cb0ef41Sopenharmony_ci 3501cb0ef41Sopenharmony_ci return output 3511cb0ef41Sopenharmony_ci} 3521cb0ef41Sopenharmony_ci 3531cb0ef41Sopenharmony_cilog.write = function (msg, style) { 3541cb0ef41Sopenharmony_ci if (!stream) { 3551cb0ef41Sopenharmony_ci return 3561cb0ef41Sopenharmony_ci } 3571cb0ef41Sopenharmony_ci 3581cb0ef41Sopenharmony_ci stream.write(this._format(msg, style)) 3591cb0ef41Sopenharmony_ci} 3601cb0ef41Sopenharmony_ci 3611cb0ef41Sopenharmony_cilog.addLevel = function (lvl, n, style, disp) { 3621cb0ef41Sopenharmony_ci // If 'disp' is null or undefined, use the lvl as a default 3631cb0ef41Sopenharmony_ci if (disp == null) { 3641cb0ef41Sopenharmony_ci disp = lvl 3651cb0ef41Sopenharmony_ci } 3661cb0ef41Sopenharmony_ci 3671cb0ef41Sopenharmony_ci this.levels[lvl] = n 3681cb0ef41Sopenharmony_ci this.style[lvl] = style 3691cb0ef41Sopenharmony_ci if (!this[lvl]) { 3701cb0ef41Sopenharmony_ci this[lvl] = function () { 3711cb0ef41Sopenharmony_ci var a = new Array(arguments.length + 1) 3721cb0ef41Sopenharmony_ci a[0] = lvl 3731cb0ef41Sopenharmony_ci for (var i = 0; i < arguments.length; i++) { 3741cb0ef41Sopenharmony_ci a[i + 1] = arguments[i] 3751cb0ef41Sopenharmony_ci } 3761cb0ef41Sopenharmony_ci 3771cb0ef41Sopenharmony_ci return this.log.apply(this, a) 3781cb0ef41Sopenharmony_ci }.bind(this) 3791cb0ef41Sopenharmony_ci } 3801cb0ef41Sopenharmony_ci this.disp[lvl] = disp 3811cb0ef41Sopenharmony_ci} 3821cb0ef41Sopenharmony_ci 3831cb0ef41Sopenharmony_cilog.prefixStyle = { fg: 'magenta' } 3841cb0ef41Sopenharmony_cilog.headingStyle = { fg: 'white', bg: 'black' } 3851cb0ef41Sopenharmony_ci 3861cb0ef41Sopenharmony_cilog.style = {} 3871cb0ef41Sopenharmony_cilog.levels = {} 3881cb0ef41Sopenharmony_cilog.disp = {} 3891cb0ef41Sopenharmony_cilog.addLevel('silly', -Infinity, { inverse: true }, 'sill') 3901cb0ef41Sopenharmony_cilog.addLevel('verbose', 1000, { fg: 'cyan', bg: 'black' }, 'verb') 3911cb0ef41Sopenharmony_cilog.addLevel('info', 2000, { fg: 'green' }) 3921cb0ef41Sopenharmony_cilog.addLevel('timing', 2500, { fg: 'green', bg: 'black' }) 3931cb0ef41Sopenharmony_cilog.addLevel('http', 3000, { fg: 'green', bg: 'black' }) 3941cb0ef41Sopenharmony_cilog.addLevel('notice', 3500, { fg: 'cyan', bg: 'black' }) 3951cb0ef41Sopenharmony_cilog.addLevel('warn', 4000, { fg: 'black', bg: 'yellow' }, 'WARN') 3961cb0ef41Sopenharmony_cilog.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!') 3971cb0ef41Sopenharmony_cilog.addLevel('silent', Infinity) 3981cb0ef41Sopenharmony_ci 3991cb0ef41Sopenharmony_ci// allow 'error' prefix 4001cb0ef41Sopenharmony_cilog.on('error', function () {}) 401