简体   繁体   English

使用nodeJS登录像pm2这样的表

[英]logging in a table like pm2 with nodeJS

I want to format all of my script's logs into a table for clarity purposes. 为了清晰起见,我想将所有脚本日志格式化为表格。 Kind of what pm2 (process manager 2) does atm for example. 例如pm2(流程管理器2)执行atm的种类。

As of today I use console.table(logs) where logs is an object of variables I want to keep track of. 从今天开始,我使用console.table(logs) ,其中log是我要跟踪的变量的对象。 It works great but I want to get rid of the trailing \\n that console.table includes. 它很好用,但我想摆脱console.table包含的尾随\\n

I would want to do something like: process.stdout.write(table(logs)) where I don't have to create the table function myself. 我想做一些类似的事情: process.stdout.write(table(logs))我不必自己创建表函数。

I tried to find the source code of console.table to copy it and remove the trailing newline as a utils function without success. 我试图找到console.table的源代码进行复制,并删除尾随换行符作为utils函数,但未成功。 any idea? 任何想法?

npm软件包c-log在此方面做得很出色: npm c-log

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM