17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/super_awesome_print.rb', line 17
def sapf(msg)
file = File.open(SuperAwesomePrint.config.log_file_path , 'a')
file.puts("*** #{Time.now} ***")
file.puts(" class: #{msg.class}") if msg.respond_to?(:class)
lines = caller[0...SuperAwesomePrint.config.caller_lines].map do |line|
root_path = SuperAwesomePrint.config.root_path
if root_path.empty?
line
else
line.gsub(root_path + '/', '')
end
end
lines.each { |l| file.puts(' trace: ' + l) }
file.puts(msg.inspect)
file.puts('*** END ***')
ensure
file.close
end
|