Class Index [+]

Quicksearch

Ramaze::Logging

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

Public Instance Methods

<<(*objects) click to toggle source
Alias for: debug
debug(*objects) click to toggle source

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
Also aliased as: <<
debug?() click to toggle source

Stub for WEBrick

     # File lib/ramaze/log/logging.rb, line 103
103:     def debug?
104:       false
105:     end
dev(*objects) click to toggle source

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
error(ex) click to toggle source

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
info(*objects) click to toggle source

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
shutdown() click to toggle source

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
tag_log(tag, meth, *msgs) click to toggle source

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
warn(*objects) click to toggle source

Converts everything given to strings and passes them on with :warn

@param [Array] objects An array of objects that need to be converted to

 strings.
    # File lib/ramaze/log/logging.rb, line 51
51:     def warn(*objects)
52:       tag_log(:warn, :to_s, *objects)
53:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.