在 rake 任务中打印到屏幕 [英] Printing to screen in a rake task

查看:32
本文介绍了在 rake 任务中打印到屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个长期运行的 rake 任务.我不时地在屏幕上打印更新,让我知道任务进行了多远.

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..."

我的问题是所有 puts 语句似乎都在某处缓冲,并且在任务完成之前不会打印到屏幕上.届时,它们将一次全部打印出来.

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?

推荐答案

STDOUT.sync = true

这篇关于在 rake 任务中打印到屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆