Module: Cowtech::RubyOnRails::Helpers::DebugHelper

Defined in:
app/helpers/cowtech/ruby_on_rails/helpers/debug_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#debug_msgObject (readonly)

Returns the value of attribute debug_msg.



11
12
13
# File 'app/helpers/cowtech/ruby_on_rails/helpers/debug_helper.rb', line 11

def debug_msg
  @debug_msg
end

Instance Method Details

#debug_dump_object(object, target = nil, method = :to_yaml) ⇒ Object



25
26
27
# File 'app/helpers/cowtech/ruby_on_rails/helpers/debug_helper.rb', line 25

def debug_dump_object(object, target = nil, method = :to_yaml)
	self.debug_log("OBJECT DUMP", object.send(method).ensure_string, target)
end

#debug_fileObject



17
18
19
# File 'app/helpers/cowtech/ruby_on_rails/helpers/debug_helper.rb', line 17

def debug_file
	@debug_file ||= Logger.new(Rails.root + "log/debug.log")
end

#debug_log(tags, msg, target = nil, no_timestamp = false) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/cowtech/ruby_on_rails/helpers/debug_helper.rb', line 29

def debug_log(tags, msg, target = nil, no_timestamp = false)
	tags = tags.ensure_array if tags.present?

	final_msg = []
	final_msg << self.debug_timestamp if !no_timestamp
	tags.collect { |tag| "[" + tag + "]" }.each { |tag| final_msg << tag } if tags.present?
	final_msg << msg
	final_msg = final_msg.join(" ")

	if !target.nil? && target.respond_to?(:debug) then
		self.debug_file.debug(final_msg)
	else
		self.debug_msgs << final_msg
	end
end

#debug_msgsObject



21
22
23
# File 'app/helpers/cowtech/ruby_on_rails/helpers/debug_helper.rb', line 21

def debug_msgs
	@debug_msgs ||= []
end

#debug_timestampObject



13
14
15
# File 'app/helpers/cowtech/ruby_on_rails/helpers/debug_helper.rb', line 13

def debug_timestamp
	"[" + Time.now.strftime("%F %T.%L %z") + "]"
end