[英]uninitialized constant Logger (NameError)
I'm trying to define a custom logger for Logger class and getting uninitialized constant Logger. 我正在尝试为Logger类定义一个自定义记录器并获取未初始化的常量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 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)
您可能需要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: 这将在您的MyLog.log文件中显示如下:
# 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!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.