I’m trying to define a custom logger for Logger class and getting uninitialized constant Logger.
The same code worked up to a few days ago, any idea what could make it break ? https://github.com/sugarso/ScrapingTheApple/blob/master/JustScrape.rb#L48
Maxims-MacBook-Air:AppleSampleCodeWorker maximveksler$ ruby JustScrape.rb
JustScrape.rb:48:in `<main>’: uninitialized constant Logger (NameError)
You probably need to require 'logger'
.
You forgot initialize the logger class at the top of your program/class with :
require 'logger'
ex:
require 'logger'
logger = Logger.new('MyLog.log')
logger.debug("Program start");
logger.info("Hello Word!")
This will show in your MyLog.log file something like:
# Logfile created on 2017-05-11 11:03:20 -0400 by logger.rb/41756
D, [2017-05-11T11:03:20.802629 #57077] DEBUG -- : Program start
I, [2017-05-11T11:03:20.802689 #57077] INFO -- : Hello Word!
More information here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With