Class: Amp::Support::Logger
Instance Attribute Summary
#singleton_object
Instance Method Summary
collapse
global_logger, method_missing
Constructor Details
#initialize(output) ⇒ Logger
Returns a new instance of Logger.
41
42
43
44
45
46
47
48
|
# File 'lib/amp/support/logger.rb', line 41
def initialize(output)
@show_times = true
@output = output
@source = ::Logger.new(output)
@indent = 0
super(@source)
self.class.singleton_object = self
end
|
Instance Method Details
#debug(input) ⇒ Object
79
|
# File 'lib/amp/support/logger.rb', line 79
def debug(input); @source.debug("\t\t"*@indent + input); self; end
|
#error(input) ⇒ Object
78
|
# File 'lib/amp/support/logger.rb', line 78
def error(input); @source.error("\t\t"*@indent + input); self; end
|
#fatal(input) ⇒ Object
77
|
# File 'lib/amp/support/logger.rb', line 77
def fatal(input); @source.fatal("\t\t"*@indent + input); self; end
|
65
66
67
68
|
# File 'lib/amp/support/logger.rb', line 65
def indent
@indent += 1
self
end
|
#info(input) ⇒ Object
76
|
# File 'lib/amp/support/logger.rb', line 76
def info(input); @source.info( "\t\t"*@indent + input); self; end
|
#level=(level) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/amp/support/logger.rb', line 82
def level=(level)
receiver = @source
case level
when :warn
receiver.level = ::Logger::WARN
when :fatal
receiver.level = ::Logger::FATAL
when :error
receiver.level = ::Logger::ERROR
when :info
receiver.level = ::Logger::INFO
when :debug
receiver.level = ::Logger::DEBUG
when :none
receiver.level = ::Logger::UNKNOWN
else
receiver.level = level
end
end
|
70
71
72
73
|
# File 'lib/amp/support/logger.rb', line 70
def outdent
@indent -= 1
self
end
|
#section(section_name) ⇒ Object
59
60
61
62
63
|
# File 'lib/amp/support/logger.rb', line 59
def section(section_name)
info("<#{section_name}>").indent
yield
outdent.info("</#{section_name}>")
end
|
#show_times=(bool) ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'lib/amp/support/logger.rb', line 50
def show_times=(bool)
if @show_times && !bool @normal_source = @source
@source = IOForwarder.new(@output)
elsif !@show_times && bool @source = @normal_source
end
end
|
#warn(input) ⇒ Object
75
|
# File 'lib/amp/support/logger.rb', line 75
def warn(input); @source.warn( "\t\t"*@indent + input); self; end
|