控制台日志?

最近,我在一个 JavaScript 程序的每一行中都加入了 console. log 语句,并发现现在这个语句更容易理解了。对于服务器端代码,特别是 Ruby,有没有一种方法可以做到这一点?我认为在 Firebug 中没有办法读取它,但是在 irb 中可以看到它吗?我应该在 Ruby 代码中放什么 console. log 等价语句?

100640 次浏览

puts is the equivalent in ruby.

Example

puts 'Hello World!'

If you are running your server in the console, you can use puts. Otherwise, you will need to write to a file, possibly via a logger (like Rails.logger.info).