C0 code coverage information
Generated on Sat Feb 02 17:44:27 +0100 2008 with rcov 0.8.1.2
Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
1 # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
2 # All files in this distribution are subject to the terms of the Ruby license.
3
4 module Ramaze
5
6 # This module provides a basic skeleton for your own loggers to be compatible.
7 # The minimal usage is like this:
8 #
9 # class MyLogger
10 # include Informing
11 #
12 # def inform(tag, *args)
13 # p tag => args
14 # end
15 # end
16
17 module Informing
18
19 # Takes the tag (:warn|:debug|:error|:info) and the name of a method to be
20 # called upon elements of msgs that don't respond to :to_str
21 # Goes on and sends the tag and transformed messages each to the #inform method.
22 # If you include this module you have to define #inform or it will raise.
23
24 def tag_inform(tag, meth, *msgs)
25 msgs.each do |msg|
26 string = (msg.respond_to?(:to_str) ? msg : msg.send(meth))
27 inform(tag, string)
28 end
29 end
30
31 # Converts everything given to strings and passes them on with :info
32
33 def info(*objects)
34 tag_inform(:info, :to_s, *objects)
35 end
36
37 # Converts everything given to strings and passes them on with :warn
38
39 def warn(*objects)
40 tag_inform(:warn, :to_s, *objects)
41 end
42
43 # inspects objects if they are no strings. Tag is :debug
44
45 def debug(*objects)
46 tag_inform(:debug, :inspect, *objects)
47 end
48
49 # inspects objects if they are no strings. Tag is :dev
50
51 def dev(*objects)
52 tag_inform(:dev, :inspect, *objects)
53 end
54
55 alias << debug
56
57 # Takes either an Exception or just a String, formats backtraces to be a bit
58 # more readable and passes all of this on to tag_inform :error
59
60 def error(ex)
61 if ex.respond_to?(:exception)
62 message = ex.backtrace[0..Global.backtrace_size]
63 message.map{|m| m.gsub!(/^#{Regexp.escape(Dir.pwd)}/, '.') }
64 message.unshift(ex.inspect)
65 else
66 message = ex.to_s
67 end
68 tag_inform(:error, :to_s, *message)
69 end
70
71 # raises
72
73 def inform(*args)
74 raise "#inform should be implemented by an instance including this module (#{self})"
75 end
76
77 # nothing
78
79 def shutdown
80 end
81
82 # stub for WEBrick
83
84 def debug?
85 false
86 end
87 end
88 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.