在 rake 任务中打印到屏幕
我有一个长时间运行的 rake 任务。我时不时地在屏幕上打印更新,让我知道任务已经完成了多少。
puts "Almost there..."
我的问题是所有的 put 语句似乎都缓冲在某处,并且在任务完成之前不会打印到屏幕上。此时,它们将被一次性打印出来。
有没有办法强制它们在任务运行时打印?
I have a long running rake task. Every now and then I print an update to the screen to let me know how far along the task has come.
puts "Almost there..."
My problem is all the puts statements seem to buffer somewhere and won't print to the screen until after the task is complete. At which point, they will be printed all at once.
Is there some way to force them to print as the task is running?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以刷新标准输出:
STDOUT.flush
May be you could flush the standart output:
STDOUT.flush