Module: Log::Comfort

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#log_deviceObject

where data is logged to



25
26
27
# File 'lib/log/comfort.rb', line 25

def log_device
  @log_device
end

Instance Method Details

#debug(text, *args) ⇒ Object

See Log::Entry.new to see what arguments are valid. Module::debug(text, *args) is the same as:

$stderr.puts(Log::Message.new(text, :debug, *args))


36
37
38
# File 'lib/log/comfort.rb', line 36

def debug(text, *args)
	(@log_device || $stderr).puts(Log::Entry.new(text.to_str, :debug, *args))
end

#error(text, *args) ⇒ Object

See Log::Entry.new to see what arguments are valid. Module::error(text, *args) is the same as:

$stderr.puts(Log::Message.new(text, :error, *args))


57
58
59
# File 'lib/log/comfort.rb', line 57

def error(text, *args)
	(@log_device || $stderr).puts(Log::Entry.new(text.to_str, :error, *args))
end

#exception(e) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/log/comfort.rb', line 69

def exception(e)
	log = @log_device || $stderr
	if log.respond_to?(:exception) then
		log.exception(e)
	else
		log.puts("#{Time.now.strftime('%FT%T')} [exception]: #{e} (#{e.class})")
		if $VERBOSE then
			prefix = "--> "
			log.puts(*e.backtrace.map { |l| prefix+l })
		end
	end
end

#fail(text, *args) ⇒ Object

See Log::Entry.new to see what arguments are valid. Module::fail(text, *args) is the same as:

$stderr.puts(Log::Message.new(text, :fail, *args))


64
65
66
# File 'lib/log/comfort.rb', line 64

def fail(text, *args)
	(@log_device || $stderr).puts(Log::Entry.new(text.to_str, :fail, *args))
end

#info(text, *args) ⇒ Object

See Log::Entry.new to see what arguments are valid. Module::info(text, *args) is the same as:

$stderr.puts(Log::Message.new(text, :info, *args))


43
44
45
# File 'lib/log/comfort.rb', line 43

def info(text, *args)
	(@log_device || $stderr).puts(Log::Entry.new(text.to_str, :info, *args))
end

#log(text, severity = :info, *args) ⇒ Object

See Log::Message.new Module::log(*args) is simply: $stderr.puts(Log::Message.new(*args))



29
30
31
# File 'lib/log/comfort.rb', line 29

def log(text, severity=:info, *args)
	(@log_device || $stderr).puts(Log::Entry.new(text.to_str, severity, *args))
end

#warn(text, *args) ⇒ Object

See Log::Entry.new to see what arguments are valid. Module::warn(text, *args) is the same as:

$stderr.puts(Log::Message.new(text, :warn, *args))


50
51
52
# File 'lib/log/comfort.rb', line 50

def warn(text, *args)
	(@log_device || $stderr).puts(Log::Entry.new(text.to_str, :warn, *args))
end