在 Powershell 中写入详细输出不会换行到命令宽度
我想将大量数据Write-Verbose
写入输出文件。我是这样做的。
Start-Transcript -Path $TargetDir\RunUnitTests.log -Width 1000000
Write-Verbose "five million character lines and stuff"
这非常有效,除了输出自动换行到控制台的标准宽度之外,这使得日志看起来非常糟糕。
我在这里找到了解决方案删除了死链接 ,但它是如此复杂和复杂,我不想只是将其放在我的脚本中的注释 #Thar be Dragons
下面。
有更好的方法吗?
I'd like to Write-Verbose
a lot of data to an out file. Here's how I'm doing it.
Start-Transcript -Path $TargetDir\RunUnitTests.log -Width 1000000
Write-Verbose "five million character lines and stuff"
This works great, except that the output is auto wrapped to the standard width of a console, this makes the log look absolutely terrible.
I found a solution heredead link removed
, but it's so involved and complicated that I don't want to just throw this in my script below a comment #Thar be dragons
.
Is there a better way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个基于
Write-Host
的非常简单的解决方法,它不存在这样的问题。在会话开始时 install/dot-source 替换默认的Write-Verbose
:然后这将根据需要工作:
也就是说:它考虑了
$VerbosePreference
,它以黄色写入主机,转录输出未包装,并且仍标记为 VERBOSE。Here is a very simple workaround based on
Write-Host
which does not have such a problem. In the beginning of the session install/dot-source the replacement of the defaultWrite-Verbose
:Then this works as needed:
That is: it takes into account
$VerbosePreference
, it writes to host in yellow, transcript output is not wrapped and it is still marked VERBOSE.