Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby gem is overriding standard library

When trying to create a new ruby logger:

logger = Logger.new('my.log')

I'm getting an error:

NoMethodError: undefined method `new' for HTTParty::Logger:Module

Creating the logger from the Rails Console works fine. When trying to create it from the class is when it's getting the error. It appears that HTTParty is interfering with it. How do I specify that I wish to use the stdlib Logger instead of the gem HTTParty's Logger?

like image 307
singularity Avatar asked Jun 17 '26 22:06

singularity


1 Answers

If you want to get the constant in 'root' namespace, you can use :: operator, like this:

logger = ::Logger.new('my.log')
like image 132
Marek Lipka Avatar answered Jun 19 '26 11:06

Marek Lipka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!