Syslog::Logger Behaviour

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

Ruby Users,
As a follow up the level= setter method indeed performs the symbol to
integer conversion (
ruby/lib/logger.rb at v2_3_3 · ruby/ruby · GitHub)
but this is seems not to be the case with Syslog::Logger (
https://github.com/ruby/ruby/blob/trunk/ext/syslog/lib/syslog/logger.rb#L163
).

The question, though, remains: is this intended? Allowing symbol to integer
conversion in Syslog::Logger would afford clients consistency.

Many thanks,

Hemal

···

On 29 December 2017 at 20:19, Hemal Varambhia <h.n.varambhia@gmail.com> wrote:

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 <020%208346%206444>
Mobile: +44 (0) 7751 879 908 <07751%20879908>

--

"Musbury",
16 Devonshire Road,
Mill Hill,
London,
NW7 1LL

Home: +44 (0) 208 346 6444
Mobile: +44 (0) 7751 879 908

Hi All,

The RubyHACK CFP will close on 1/1/18 for the conference in Salt Lake City Utah on 5/3 and 5/4. This is year 2 of our event and we hope to top what was a great event last year. If you’re a seasoned presenter or someone who wants to get in front of a great supportive group we have room for you. Please check us out at http://rubyhack.com <http://rubyhack.com/> and submit your presentation for review!

Thanks,

Max