rudionrails / yell-adapters-gelf

Graylog2 adapter for Yell
MIT License
3 stars 4 forks source link

Symbolize option keys #7

Closed OscarBarrett closed 10 years ago

OscarBarrett commented 10 years ago

When using a yaml configuration file to initialize Yell loggers, the keys come through as strings instead of symbols (even when using symbolized keys in the yaml). Example configuration file:

environment:
  :format: '<%= Yell::ExtendedFormat %>'
  :level: 'gte.debug'
  :adapters:
    - :gelf:
        :host: 'graylog_host.com'
        :port:  12345
        :facility:  'custom_facility'
        :level: 'gte.error'

Logging out options in setup returns the following:

#<Yell::Adapters::Collection:0x00000000000000
  @options={
      "format"=>"%d [%5L] %p %h : %m\n",
      "level"=>"gte.debug",
      "adapters"=>[{
          "gelf"=>{
              "host"=>"graylog_host.com",
              "port"=>12345,
              "facility"=>"custom_facility",
              "level"=>"gte.error"
          }
      }]
  },
  @collection=[#<Yell::Adapters::Gelf level: #<Yell::Level severities: ERROR, FATAL, UNKNOWN>>]
>

Compared with creating a logger using Yell.new:

#<Yell::Adapters::Collection:0x00000000000000
  @options={
    :host=>"graylog_host.com",
    :port=>12345,
    :facility=>"custom_facility",
    :level=>"gte.error"
  },
  @collection=[#<Yell::Adapters::Gelf level: #<Yell::Level severities: ERROR, FATAL, UNKNOWN>>]>

This PR symbolizes the keys of the options hash, allowing the gelf adapter to properly initialize using values in the config file rather than just falling back to the defaults. It doesn't symbolize the gelf hash itself, but from my testing it works fine as long the base keys are symbolized.

rudionrails commented 10 years ago

Hi, yea this is a bug indeed. I've updated Yell a while ago and it seems that I did not update the gelf adapter. There's no need to change the hash keys - yell has an own method to doing this. I'll let you know when I've done the change.

OscarBarrett commented 10 years ago

Hey, just checking up on this again. I've seen your commits and it works, are there any blockers from getting a new version up on rubygems?

rudionrails commented 10 years ago

Just released v2.0.1

OscarBarrett commented 10 years ago

Thanks!