This module provides a basic skeleton for your own loggers to be compatible.
@example
class MyLogger include Logging def log(tag, *args) p tag => args end end
Inspects objects if they are no strings. Tag is :debug
@param [Array] objects An array of objects that will be inspected.
# File lib/ramaze/log/logging.rb, line 60 60: def debug(*objects) 61: tag_log(:debug, :inspect, *objects) 62: end
Stub for WEBrick
# File lib/ramaze/log/logging.rb, line 103 103: def debug? 104: false 105: end
Inspects objects if they are no strings. Tag is :dev
@param [Array] objects An array of objects that will be inspected.
# File lib/ramaze/log/logging.rb, line 69 69: def dev(*objects) 70: tag_log(:dev, :inspect, *objects) 71: end
Takes either an Exception or just a String, formats backtraces to be a bit more readable and passes all of this on to tag_log :error
@param [Object] ex The exception that was raised.
# File lib/ramaze/log/logging.rb, line 81 81: def error(ex) 82: if ex.respond_to?(:exception) 83: message = ex.backtrace 84: message.map!{|m| m.to_s.gsub(/^#{Regexp.escape(Dir.pwd)}/, '.') } 85: message.unshift(ex.inspect) 86: else 87: message = ex.to_s 88: end 89: tag_log(:error, :to_s, *message) 90: end
Converts everything given to strings and passes them on with :info
@param [Array] objects An array of objects that need to be converted to
strings.
# File lib/ramaze/log/logging.rb, line 41 41: def info(*objects) 42: tag_log(:info, :to_s, *objects) 43: end
Nothing.
THINK: Is this really required? It doesn’t do anything anyway.
# File lib/ramaze/log/logging.rb, line 97 97: def shutdown 98: end
Takes the tag (:warn|:debug|:error|:info) and the name of a method to be called upon elements of msgs that don’t respond to :to_str Goes on and sends the tag and transformed messages each to the # method. If you include this module you have to define # or it will raise.
@param [String] tag The level of the log message. @param [String] method @param [Array] msgs The data that should be logged.
# File lib/ramaze/log/logging.rb, line 28 28: def tag_log(tag, meth, *msgs) 29: msgs.each do |msg| 30: string = (msg.respond_to?(:to_str) ? msg : msg.send(meth)) 31: log(tag, string) 32: end 33: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.