lib/blinkenstein/logging.rb in blinkenstein-0.2.0 vs lib/blinkenstein/logging.rb in blinkenstein-0.2.1
- old
+ new
@@ -1,21 +1,32 @@
+require "logger"
+
module Blinkenstein
+ class << self
+ attr_accessor :logger
+ end
+
+ @logger = Logger.new(STDOUT)
+ @logger.level = ENV["DEBUG"] ? Logger::DEBUG : Logger::INFO
+
module Logging
- def logger
- @logger ||= Logging.logger_for(self.class.name)
+ def debug(*args)
+ Blinkenstein.logger.debug(*args) if Blinkenstein.logger
end
- @loggers = {}
+ def info(*args)
+ Blinkenstein.logger.info(*args) if Blinkenstein.logger
+ end
- class << self
- def logger_for(classname)
- @loggers[classname] ||= configure_logger_for(classname)
- end
+ def warn(*args)
+ Blinkenstein.logger.warn(*args) if Blinkenstein.logger
+ end
- def configure_logger_for(classname)
- logger = Logger.new(STDOUT)
- logger.progname = classname
- logger
- end
+ def error(*args)
+ Blinkenstein.logger.error(*args) if Blinkenstein.logger
+ end
+
+ def fatal(*args)
+ Blinkenstein.logger.error(*args) if Blinkenstein.logger
end
end
end