summaryrefslogtreecommitdiff
path: root/lib/ohai/log.rb
diff options
context:
space:
mode:
authorMathieu Sauve-Frankel <msf@kisoku.net>2009-09-08 17:52:43 +0900
committerAJ Christensen <aj@junglist.gen.nz>2009-10-02 17:37:25 +1300
commit85c5f9d5bbb7ed73894a570a83716e8424dd76de (patch)
tree16e5bd9451a015622282c85df4ac6710c26949b7 /lib/ohai/log.rb
parent6f2a3620474004ee3cfe4f476dda777aefd5add0 (diff)
downloadohai-85c5f9d5bbb7ed73894a570a83716e8424dd76de.tar.gz
refactor ohai to use mixlib
Diffstat (limited to 'lib/ohai/log.rb')
-rw-r--r--lib/ohai/log.rb69
1 files changed, 3 insertions, 66 deletions
diff --git a/lib/ohai/log.rb b/lib/ohai/log.rb
index c8f5509a..1af4cdc3 100644
--- a/lib/ohai/log.rb
+++ b/lib/ohai/log.rb
@@ -17,73 +17,10 @@
#
require 'ohai/config'
-require 'ohai/log/formatter'
-require 'logger'
+require 'mixlib/log'
module Ohai
class Log
-
- @logger = nil
-
- class << self
- attr_accessor :logger #:nodoc
-
- # Use Ohai::Logger.init when you want to set up the logger manually. Arguments to this method
- # get passed directly to Logger.new, so check out the documentation for the standard Logger class
- # to understand what to do here.
- #
- # If this method is called with no arguments, it will log to STDOUT at the :info level.
- #
- # It also configures the Logger instance it creates to use the custom Ohai::Log::Formatter class.
- def init(*opts)
- if opts.length == 0
- @logger = Logger.new(STDOUT)
- else
- @logger = Logger.new(*opts)
- end
- @logger.formatter = Ohai::Log::Formatter.new()
- level(Ohai::Config.log_level)
- end
-
- # Sets the level for the Logger object by symbol. Valid arguments are:
- #
- # :debug
- # :info
- # :warn
- # :error
- # :fatal
- #
- # Throws an ArgumentError if you feed it a bogus log level.
- def level(loglevel)
- init() unless @logger
- case loglevel
- when :debug
- @logger.level = Logger::DEBUG
- when :info
- @logger.level = Logger::INFO
- when :warn
- @logger.level = Logger::WARN
- when :error
- @logger.level = Logger::ERROR
- when :fatal
- @logger.level = Logger::FATAL
- else
- raise ArgumentError, "Log level must be one of :debug, :info, :warn, :error, or :fatal"
- end
- end
-
- # Passes any other method calls on directly to the underlying Logger object created with init. If
- # this method gets hit before a call to Ohai::Logger.init has been made, it will call
- # Ohai::Logger.init() with no arguments.
- def method_missing(method_symbol, *args)
- init() unless @logger
- if args.length > 0
- @logger.send(method_symbol, *args)
- else
- @logger.send(method_symbol)
- end
- end
-
- end # class << self
+ extend Mixlib::Log
end
-end \ No newline at end of file
+end