向标准输出添加时间戳
我发现这两个类似的问题: 将 stdout 重定向到文件并添加时间戳 和 如何向 STDERR 重定向添加时间戳 以将 stdout 重定向到文件。
我想在将行写入文件时添加时间戳。目前,我像这样编写日志文件:
START cmd /c %PATH_STLink-OPENOCD%\openocd.exe -f %CD%\%CFG_File% -s %PATH_SUPPORTFILES% -d0 ^> output.txt
如果输出看起来像这样(使用%date%和%time%),那就太好了。希望这是可能的:
[10.03.2022, 16:11:40,45]output of openocd.exe
[10.03.2022, 16:11:42,21]output of openocd.exe
[10.03.2022, 16:11:43,65]output of openocd.exe
非常感谢!
i found these two similar questions: Redirect stdout to a file and add a timestamp and How to add timestamp to STDERR redirection to redirect stdout to a file.
I want to add a timestamp when the line is written to the file. At the moment I wrtie the log file like this:
START cmd /c %PATH_STLink-OPENOCD%\openocd.exe -f %CD%\%CFG_File% -s %PATH_SUPPORTFILES% -d0 ^> output.txt
It would be nice, when the output could look like this (using %date% and %time%). Hopefully this is possible:
[10.03.2022, 16:11:40,45]output of openocd.exe
[10.03.2022, 16:11:42,21]output of openocd.exe
[10.03.2022, 16:11:43,65]output of openocd.exe
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该将
set/p
的提示放入新文件output.txt
中,不带换行符;然后附加你想要的数据。should put the prompt for the
set/p
into the new fileoutput.txt
with no newline; then append the data you want.