wbailey / command_line_reporter

A gem for making it easy to produce a report while a ruby script is executing
Apache License 2.0
432 stars 23 forks source link

Issue with newrelic_rpm #13

Open pnock opened 10 years ago

pnock commented 10 years ago

Hi Wes!

I updated my newrelic_rpm from 3.6.6.147 to 3.9.1.236, and started getting: "..../gems/command_line_reporter-3.3.2/lib/command_line_reporter.rb:45:in `rescue in formatter='"

Looks like the newrelic gem is doing this "@log.formatter = Proc.new ..." around line 167 of agent_logger.rb, which is conflicting with your formatter= method.

I tried a quick hack with this:

38 def formatter=(type = 'nested') 39 return type if type.class != String 40 name = type.capitalize + 'Formatter' 41 klass = %W{CommandLineReporter #{name}}.inject(Kernel) {|s,c| s.const_get(c)} 42
43 # Each formatter is a singleton that responds to #instance 44 @formatter = klass.instance 45 rescue 46 raise ArgumentError, 'Invalid formatter specified' 47 end

which seemed to stop things from crashing, but haven't had much time to see if this is appropriate or not. Any thoughts?

wbailey commented 10 years ago

That looks pretty good at first glance. Go ahead and make a pull request and I'll have a look this weekend.