我可以将此输出的内容写入文件吗?我正在使用 debug 模块来记录消息,我希望能够将它们通过管道传输到文件。然而它并没有按预期工作。
$ DEBUG=* node -e 'var debug = require("debug")("test"); debug("hello world")'
test hello world +0ms
$ DEBUG=* node -e 'var debug = require("debug")("test"); debug("hello world")' > temp.txt
test hello world +0ms
刚刚尝试过,也没有收到任何输出。
$ { DEBUG=* node -e "var debug = require('debug')('test'); debug('hello world')"; } >temp.txt
test hello world +0ms
debug
。DEBUG_FD=3
env 标志以及 3>
进行管道传输这是一个例子。
$ DEBUG_FD=3 DEBUG=foo node -e "require('debug')('foo')('hello')" 3> foo.txt
来自存储库的问题请求/问题:有没有办法让调试记录到文件?
使用
DEBUG_FD=3
对我来说不起作用。
对我有用的选项是使用
2>
进行管道传输:
DEBUG=* node --inspect=0.0.0.0:9229 . 2> log.txt