Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method log_level #292

Closed
sudhirarora opened this issue Jun 6, 2012 · 37 comments
Closed

undefined method log_level #292

sudhirarora opened this issue Jun 6, 2012 · 37 comments
Milestone

Comments

@sudhirarora
Copy link

why log_level method is removed from config.rb.

NoMethodError:
undefined method `log_level=' for #Savon::Config:0x4f18179d

@rubiii
Copy link
Contributor

rubiii commented Jun 6, 2012

that's probably a pretty hard change. this is mentioned in the changelog, but it's quite hidden. sorry.
logging has been moved to a wrapper object. here's how you can change the log settings:

Savon.configure do |config|
  config.logger.subject = Rails.logger
  config.logger.level   = :info
  config.logger.filter << :password
end

edit: please note that with v0.9.12, the log wrapper has been moved to Savon.config._logger
and backwards compatibility with the "old way" of specifying log config has been restored.

@berrettbrothers
Copy link

I'm also having trouble with the new logger, but more particularly trying to turn logging off altogether. I went diving through the source but haven't figured out how to correctly do this yet. I am turning it off as it interrupts spec output in RSpec2 for a gem I'm building that's depending on Savon. I've tried numerous things including:

Savon.configure do |config|
  config.logger.subject = Savon::Logger.new("/dev/null")
end

This isn't doing anything for me, however. Am I completely off track here?

@rohitn
Copy link

rohitn commented Jun 7, 2012

Hi Daniel,

The removal of log_level should not have been made in a patch version, the public API has changed. Please use semantic versioning http://semver.org/spec/v1.0.0.html in the future.

The documentation has not been updated. See the global configuration section here http://savonrb.com/

As a result of this change the Google ads api Ruby wrapper broke. http://code.google.com/p/google-api-ads-ruby/

Thank you for Savon. It is crucial to our business.

Please let me know how we can help to make it even better. We can help.

Rohit

@berrettbrothers
Copy link

"Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable." The public API doesn't stabilize until major version 1. I think Daniel is still well within the Semantic Versioning bounds here.

@berrettbrothers
Copy link

Sorry, I take that back and concede your point. The minor version change is for introducing new changes that are more than bug fixes. So, what @rohitn is saying is that it really should've been v0.10.0 to introduce new functionality. This would allow developers to use '~> 0.9.8' in a Gemfile, for example, which would have prevented any problems with new functionality appearing in the 0.9.x minor version. I suppose this is more of a guideline though since the specification does state that the public API is not to be considered stable in the 0.x.x major version.

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

even though you "shouldn't expect" something 0.x to have a stable api, i totally agree with your point.
the change was too hard for a library that has been around for years and semver is definitely the way to go.

i just released v0.9.12 which restores the log, log_level and logger setter methods (b155907)
and delegates to the new log wrapper for backwards compatibility.

@lassecapel
Copy link

Think this fix doesn't work properly:

NoMethodError: undefined method `logger' for #Savon::Config:0x007fd2d5450d58

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

there's no logger method. you can access the log wrapper via Savon.config._logger if you need it.

@trevorhiley
Copy link

I don't think anywhere in my code am I referring to logger though, it seems in the Savon config that is the default it is still trying to access logger?

rubiii added a commit that referenced this issue Jun 7, 2012
@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

thanks. i don't have a stacktrace, but v0.9.13 should fix this. sorry again!

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

btw. if this finally works and i don't get any other important issues, i'll release v1.0.0 with no changes to manifest the api.

@calas
Copy link

calas commented Jun 7, 2012

is 0.9.13 backward compatible with 0.9.11 then? I mean the logger stuff, I change my code yesterday to use the new logger and today it doesn't work :(

I get your point about 0.xx versions and stable api.

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

the log config should be mostly backward compatible with v0.9.9. this was and is the syntax:
https://github.com/rubiii/savon/blob/master/CHANGELOG.md#0912-2012-06-07

@voipscout
Copy link

v0.9.13 didn't fix it, at least not for me, still 'log_level' undefined method.

@sudhirarora
Copy link
Author

using 0.9.13

NameError:
undefined local variable or method `log_level' for #Savon::Config:0x70dcef5

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

can you please post the complete stacktrace?

rubiii added a commit that referenced this issue Jun 7, 2012
@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

v0.9.14

@sudhirarora
Copy link
Author

0.9.13 stacktrace you asked for

msg:#<NameError: undefined local variable or method `log_level' for #<Savon::Config:0x78b0a381>>
/home/sudhir/.rvm/gems/jruby-1.6.2/gems/savon-0.9.13/lib/savon/config.rb:24:in `log_level='
/home/sudhir/.rvm/gems/jruby-1.6.2/gems/google-ads-common-0.7.1/lib/ads_common/savon_service.rb:72:in `create_savon_client'
/home/sudhir/.rvm/gems/jruby-1.6.2/gems/savon-0.9.13/lib/savon.rb:14:in `configure'
/home/sudhir/.rvm/gems/jruby-1.6.2/gems/google-ads-common-0.7.1/lib/ads_common/savon_service.rb:70:in `create_savon_client'
/home/sudhir/.rvm/gems/jruby-1.6.2/gems/google-ads-common-0.7.1/lib/ads_common/savon_service.rb:42:in `initialize'
/home/sudhir/.rvm/gems/jruby-1.6.2/gems/google-adwords-api-0.6.1/lib/adwords_api/v201109/serviced_account_service.rb:17:in `initialize'
/home/sudhir/.rvm/gems/jruby-1.6.2/gems/google-ads-common-0.7.1/lib/ads_common/api.rb:217:in `prepare_wrapper'
/home/sudhir/.rvm/gems/jruby-1.6.2/gems/google-ads-common-0.7.1/lib/ads_common/api.rb:81:in `service'
/home/sudhir/projects/vulcan/vulcan-google/lib/vulcan-google/mcc_account.rb:24:in `fetch_accounts'
/home/sudhir/projects/vulcan/vulcan-google/lib/vulcan-google/mcc_account.rb:17:in `accounts'
/home/sudhir/projects/vulcan/vulcan-google/lib/vulcan-google.rb:181:in `accounts'
/home/sudhir/projects/vulcan/vulcan-google/bin/vulcan-google:118:in `__file__'
org/jruby/RubyProc.java:268:in `call'
org/jruby/RubyProc.java:228:in `call'
/home/sudhir/.rvm/gems/jruby-1.6.2/gems/gli-1.6.0/lib/gli.rb:275:in `proceed?'
/home/sudhir/.rvm/gems/jruby-1.6.2/gems/gli-1.6.0/lib/gli.rb:248:in `run'
/home/sudhir/projects/vulcan/vulcan-google/bin/vulcan-google:140:in `(root)'
error: undefined local variable or method `log_level' for #<Savon::Config:0x78b0a381>

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

yep. thanks. that should finally be fixed with v0.9.14. i yanked v0.9.12 and v0.9.13 to minimize the confusion.

@berrettbrothers
Copy link

Ok, so I tried this:

Savon.configure do |config|
    config.log = false
end

In my spec_helper.rb file with RSpec and I'm still getting all the debug output to STDOUT. This was working for me before so I'm not sure what I'm missing here. Is it possibly something with the new Logger class that changed the behavior here?

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

there's a spec for that. which of the various versions are you using?

@berrettbrothers
Copy link

The latest. I'll take a look at your example.

@berrettbrothers
Copy link

Oh, actually, here's another interesting thing. I'm extending Savon::Model and I forgot that last night I considered this might not be properly affected by the global logger config setting. Is that possible?

@berrettbrothers
Copy link

Well, it looks like it's supposed to clone the global config:

def config
  @config ||= Savon.config.clone
end

So I suppose I'm off base there.

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

when you're extending the model, the global config is memoized per extended class:
https://github.com/rubiii/savon/blob/master/lib/savon/model.rb#L53-55

let me know if there's something wrong with it.

@berrettbrothers
Copy link

The Savon::Model code looks fine. I just can't figure out why I'm still getting log output even though I'm calling the configure block and setting log to false before my tests. It's just not adding up.

@berrettbrothers
Copy link

I even tried adding:

config.log = false

to my class that's extending Savon::Model with no luck . . .

@trevorhiley
Copy link

This fixed my issue with logger after I updated my gem. I'm using it in
the model?

On Thu, Jun 7, 2012 at 10:24 AM, Berrett Brothers <
reply@reply.github.com

wrote:

I even tried adding:

config.log = false

to my class that's extending Savon::Model with no luck . . .


Reply to this email directly or view it on GitHub:
https://github.com/rubiii/savon/issues/292#issuecomment-6178814

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

the log config impl. for the model used two different configs.
i changed it to only use the global one c636b7d.

try changing the log level per class by accessing the config stored on the client instance:

class User
  extend Savon::Model

  client.config.log = false

end

@berrettbrothers
Copy link

Ok, I've got a Base class extending Savon::Model and then another class inheriting from my base class. If I drop that line in the Base class it does nothing for me. If I drop it in the child class it eliminates the log ouput. However, I was hoping to only eliminate this during my tests with one fell swoop on the global config. I will probably end up redirecting the output to my gem's own Logger implementation eventually but it's not implemented yet. I think we're getting somewhere though.

@berrettbrothers
Copy link

Oh, I just realized that you removed that in the patch you mentioned. Not in a new version of the gem yet though, correct?

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

yep. didn't want to release yet another version until someone tested against master.

@berrettbrothers
Copy link

Ah, I see. I can pull from master this afternoon or evening and test with my project to see how it works. Thanks.

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

thank you!

@sudhirarora
Copy link
Author

I haven't tested the latest code from master but it looks like the original issue I had is now resolved in new google-ads-common 0.7.2 released today. I have tested against 0.9.11 and it works fine. I am not getting the same error anymore.

http://code.google.com/p/google-api-ads-ruby/issues/detail?id=75&can=1&sort=-id

http://code.google.com/p/google-api-ads-ruby/source/diff?spec=svn71fec6e44d5cf1ca3f86108a41bbbb5b633438fe&r=71fec6e44d5cf1ca3f86108a41bbbb5b633438fe&format=side&path=/ads_common/lib/ads_common/savon_service.rb

@rubiii
Copy link
Contributor

rubiii commented Jun 8, 2012

great. closing this issue cause every bug seems to be fixed.
feel free to re-open if the log behavior in v0.9.14 still causes an issue.

@rubiii rubiii closed this as completed Jun 8, 2012
@sudhirarora
Copy link
Author

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants