首页 > Web开发 > 详细

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

时间:2018-07-10 19:01:55      阅读:181      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!