日志转换失败。 Fixnum与String的比较失败

时间:2014-05-26 17:43:23

标签: ruby logging

我正在尝试使用ruby记录器。我收到错误:log shifting failed. comparison of Fixnum with String failed我不明白为什么。

这是我的代码:

require 'logger'
require 'yaml'
require 'net/ssh'

logger = Logger.new('/tmp/log.log', 10, 'daily')
logger.level = Logger::DEBUG

Net::SSH.start(host, user, forward_agent: true) do |ssh|
  output =  ssh.exec! "cat #{app}/shared/config/database.yml"
  ssh.loop
  logger.debug output

  stuff = YAML.load(output)
  logger.debug stuff['database']

  ssh.loop
  ssh.close
end

错误消息似乎意味着它期待一个Fixnum?

1 个答案:

答案 0 :(得分:8)

来自documentation

new(name, shift_age = 7, shift_size = 1048576)
new(name, shift_age = 'weekly')

所以我认为你使用带有错误参数的构造函数。

尝试:

logger = Logger.new('/tmp/log.log', 'daily', 10)