【发布时间】:2011-11-22 02:11:58
【问题描述】:
我有一个 Rails 应用程序部署到 heroku,需要在 heroku console 中处理一些数据。为了帮助我做到这一点,我在我的 lib 目录中创建了cmd.rb,其中包含一些方法。这是它的样子:
class Cmd
def self.hello
puts "Hello World"
end
def self.create_member
# real code with multiple "puts" statements here
end
end
这就是我尝试在 heroku 控制台中运行它时得到的结果:
$ heroku console
Ruby console for myapp.heroku.com
>> puts User.count
515
=> nil
>> 3.times {|i| puts i}
0
1
2
=> 3
>> require "#{Rails.root}/lib/cmd"
=> true
>> Cmd
=> Cmd
>> Cmd.hello
=> nil
上面明显缺少“Hello World”。现在,如果我在另一个终端窗口中执行此操作,我可以看到输出:
heroku logs --tail
但该输出中有很多噪音,我希望能够逐步看到事物。
【问题讨论】:
-
我注意到,如果我使用
heroku logs --tail --ps web.1,我得到的日志输出会少一些,尽管它仍然很吵。
标签: ruby-on-rails printing console heroku logging