Reputation: 30172
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)
Upvotes: 5
Views: 9023
Reputation: 1691
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
Upvotes: 1