码迷,mamicode.com
首页 > Web开发 > 详细

[Tools] Using colours in a NodeJS terminal - make your output pop

时间:2018-07-10 19:12:47      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:span   bsp   nodejs   using   console   output   bug   分享   magent   

Use can use colour and styles to make it easy to spot errors and group common functionality into blocks when viewing a NodeJS console.

This lesson will show how to enhance an Express application to highlight errors, display setup issues to developers and group together output using the color npm package, both in the console and Papertrail which is a hosted logging service.

We use the Colors package in this lesson.

 

技术分享图片

 

It is quite useful, make debugging a little bit easier,

console.log(colors.white.bold.bgBlue(" ------Console JOB ---------"))

logger.info(colors.white.bgBlue(" ------BEGIN JOB ---------"));
logger.info(colors.white.bgBlue("Running Job XYZ"));
logger.info(colors.white.bgBlue(" ------END JOB ---------"));
logger.info(colors.white.bgMagenta(" ------BEGIN PAY ---------"));
logger.info(colors.white.bgMagenta("Running Job XYZ"));
logger.info(colors.white.bgMagenta(" ------END PAY ---------"));
logger.error(colors.white.bgMagenta(" ------END PAY ---------"));
logger.info(
  colors.yellow.inverse(
    " **** CAUTION Running in Test Mode - Check variables file ****"
  )
);
logger.info(colors.rainbow(` running → http://localhost:3000`));

 

[Tools] Using colours in a NodeJS terminal - make your output pop

标签:span   bsp   nodejs   using   console   output   bug   分享   magent   

原文地址:https://www.cnblogs.com/Answer1215/p/9290890.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!