繁体   English   中英

Bunyan 日志打印不漂亮

[英]Bunyan logs not pretty-printing

我正在使用 windows 作为我的终端使用 powershell。 我有一个使用 bunyan 的非常简单的 nodejs 应用程序。 运行时会产生以下 output:

C:\dev\proj\bunyanTest> node bunyanTest.js
{"name":"name","hostname":"computer","pid":14032,"level":30,"msg":"Test...","time":"2021-03-02T16:41:46.826Z","v":0}
C:\dev\proj\bunyanTest> 

请注意,程序会立即终止。

我想要 pipe 这个 output 以便它打印得漂亮。 我做了以下事情:

C:\dev\proj\bunyanTest> npm install --global bunyan
.
.
. npm successfully installs bunyan globally
.
.
C:\dev\proj\bunyanTest> node bunyanTest.js | bunyan

不幸的是,这导致没有 output,没有终止(我需要按 ctrl+c 来终止)。

bunyan 文档演示了如何使用本地 bunyan 安装(在 node_modules 中):

C:\dev\proj\bunyanTest> node bunyanTest.js | ./node_modules/.bin/bunyan

但对我来说,这会产生相同的空结果(没有 output,没有终止)。

我怎样才能让我的日志打印得漂亮?

(我的源代码相关吗?似乎最重要的是 output。)

Windows powershell 不支持 pipe 运算符 ( | ) 流式传输 output。这就是为什么这不起作用。

暂无
暂无

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

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