Dear Ruby Users,
Currently I am investigating some behaviour around instances of the
Syslog::Logger class that, to me, looks strange (more likely my ignorance).
Normally, with Ruby's standard Logger class, it is possible to do the
following:
logger.level = :INFO
In the back this is converted to the appropriate integer (in this case 1):
#<Logger:... @level=1...>
However, with Syslog::Logger, doing the same and then invoking:
logger.info 'msg'
yields an argument error:
ArgumentError: comparison of Symbol with 1 failed
from
/Users/hemalvarambhia/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/syslog/logger.rb:205:in
`<='
from
/Users/hemalvarambhia/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/syslog/logger.rb:205:in
`add'
from
/Users/hemalvarambhia/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/syslog/logger.rb:111:in
`info'
from (irb):11
from /Users/hemalvarambhia/.rvm/rubies/ruby-2.3.3/bin/irb:11:in `<main>'
This is because the object stores the symbol directly, without conversion
to integer:
#<Syslog::Logger:...@level=:INFO, ...>
I would've expected Syslog::Logger to convert symbol to integer at the back
like Ruby's standard Logger.
Is this intended behaviour?
Many thanks,
Hemal
···
--
"Musbury",
16 Devonshire Road,
Mill Hill,
London,
NW7 1LL
Home: +44 (0) 208 346 6444
Mobile: +44 (0) 7751 879 908