log_

2019-10-21 admin

log_是什么

什么是log_,console.log in color and with custom prefixes

log_使用教程帮助文档

log_

console.log + color + prefix for node.js

Installation

npm install --save log_

Usage

var log = require('log_')('server', 'blue');

// Basic logging
log('starting on port 8080');

// Error messages
log.warn('server crashed!');

This logs the following:

[server] starting on port 8080 [server] server crashed!

Available Colors

var Log = require('log_');
console.log(Log.colors);

// outputs the following
{
  'reset':      '\u001b[0m',
  'bold':       '\u001b[1m',
  'italic':     '\u001b[3m',
  'underline':  '\u001b[4m',
  'blink':      '\u001b[5m',
  'black':      '\u001b[30m',
  'red':        '\u001b[31m',
  'green':      '\u001b[32m',
  'yellow':     '\u001b[33m',
  'blue':       '\u001b[34m',
  'magenta':    '\u001b[35m',
  'cyan':       '\u001b[36m',
  'white':      '\u001b[37m'
}

Enabling and Disabling

var Log, log;

Log = require('log_');
log = Log('test', 'green');

log('enabled by default');

Log.disable();
log('disabling the logs');
log.warn('no one can hear you');

Log.enable();
log('enable the logs again');

[server] enabled by default [server] enable the logs again

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-77929.html

文章标题:log_

回到顶部