简体   繁体   English

Bunyan 日志打印不漂亮

[英]Bunyan logs not pretty-printing

I am working with windows using powershell as my terminal.我正在使用 windows 作为我的终端使用 powershell。 I have an extremely simple nodejs app that uses bunyan.我有一个使用 bunyan 的非常简单的 nodejs 应用程序。 When run it produces the following output:运行时会产生以下 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> 

Note that the program terminates immediately.请注意,程序会立即终止。

I want to pipe this output so that it is pretty-printed.我想要 pipe 这个 output 以便它打印得漂亮。 I have done the following:我做了以下事情:

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

Unfortunately this results in no output, no termination (I need to hit ctrl+c to terminate).不幸的是,这导致没有 output,没有终止(我需要按 ctrl+c 来终止)。

The bunyan docs demonstrate using the local bunyan installation (in node_modules): bunyan 文档演示了如何使用本地 bunyan 安装(在 node_modules 中):

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

But for me this produces the same empty result (no output, no termination).但对我来说,这会产生相同的空结果(没有 output,没有终止)。

How can I get my log pretty-printed?我怎样才能让我的日志打印得漂亮?

(Is my source code relevant? It seems like all that should matter is the output.) (我的源代码相关吗?似乎最重要的是 output。)

Windows powershell doesn't support the pipe operator ( | ) with streaming output. That's why this wasn't working. Windows powershell 不支持 pipe 运算符 ( | ) 流式传输 output。这就是为什么这不起作用。

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

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