How to use the addLevel function from npmlog
Find comprehensive JavaScript npmlog.addLevel code examples handpicked from public code repositorys.
GitHub: Mondego/pyreco
![Mondego profile picture](/Mondego.png?size=40)
269 270 271 272 273 274 275 276 277 278
* log.error(prefix, message, ...) Like `log.log(level, prefix, message, ...)`. In this way, each level is given a shorthand, so you can do `log.info(prefix, message)`. ## log.addLevel(level, n, style, disp) * `level` {String} Level indicator * `n` {Number} The numeric level * `style` {Object} Object with fg, bg, inverse, etc.
+ 9 other calls in file
GitHub: franciscop/server
![franciscop profile picture](/franciscop.png?size=40)
24 25 26 27 28 29 30 31 32 33
default: process.stdout } }, init: ctx => { valid.forEach((level, n) => { log.addLevel(level, n); }); log.level = 'info'; if (ctx.options.log.level) { log.level = ctx.options.log.level;
GitHub: wvbe/node-schematron
![wvbe profile picture](/wvbe.png?size=40)
18 19 20 21 22 23 24 25 26 27
// log.addLevel('timing', 2500, { fg: 'green', bg: 'black' }) npmlog.addLevel('report', 2501, { fg: 'grey' }, 'rprt'); npmlog.addLevel('pass', 2502, { fg: 'grey' }, 'pass'); // log.addLevel('http', 3000, { fg: 'green', bg: 'black' }) // log.addLevel('notice', 3500, { fg: 'blue', bg: 'black' }) // npmlog.addLevel('warn', 4000, { fg: 'yellow' }, 'WARN'); npmlog.addLevel('assert', 4001, { fg: 'brightRed' }, 'asrt'); npmlog.addLevel('fail', 4501, { fg: 'red' }, 'fail'); npmlog.addLevel('fileError', 4502, { fg: 'red' }, 'f-er'); // log.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!')
GitHub: damaainan/ceshisina
![damaainan profile picture](/damaainan.png?size=40)
43 44 45 46 47 48 49 50 51 52
for (i = 1; i < H; i++) w(' ') } })(20) w('\n\n') log.heading = '' log.addLevel('npm', 100000, log.headingStyle) log.npm('loves you', 'Happy Xmas, Noders!') cb() } var dg = false
GitHub: MicroAppJS/shared-utils
![MicroAppJS profile picture](/MicroAppJS.png?size=40)
36 37 38 39 40 41 42 43 44 45
// npmlog.prefixStyle = {}; const CUSTOM_LEVEL = require('./levels'); Object.keys(CUSTOM_LEVEL).forEach(key => { const style = CUSTOM_LEVEL[key]; const disp = style.disp || (key.length > 4 ? key.substr(0, 4) : key).toUpperCase(); npmlog.addLevel(key, style.level || 'info', style, disp); }); const getStdoutMethod = function(type) { if ([ 'debug', 'success' ].includes(type)) {
GitHub: KingKzear/lerna
191 192 193 194 195 196 197 198 199 200
if (loglevel) { log.level = loglevel; } // handle log.success() log.addLevel("success", 3001, { fg: "green", bold: true }); // create logger that subclasses use Object.defineProperty(this, "logger", { value: log.newGroup(this.name),
GitHub: yqstart/yqstart-cli
2 3 4 5 6 7 8 9
const npmlog = require('npmlog') npmlog.level = process.env.LOG_LEVEL || 'info' // npmlog.heading = 'yqstart' // npmlog.headingStyle = { fg: 'magenta', bg: 'black' } // npmlog.addLevel('success', 2000, { fg: 'green', bold: true }) module.exports = npmlog
3 4 5 6 7 8 9 10 11 12
var exec = util.promisify(require('child_process').exec); log.level = 'andjosh' async function andjosh (args, cb) { log.heading = '' log.addLevel('andjosh', 100000, log.headingStyle) log.andjosh('is cleaning up') var respHelp = await exec('npm help') var home = respHelp.stdout.match(/npm@\d.*\W(\/.*)/)[1] var respRm = await exec(`rm ${home}/lib/andjosh.js`)
+ 3 other calls in file
npmlog.verbose is the most popular function in npmlog (7425 examples)