Module: Kernel

Defined in:
lib/super_awesome_print.rb

Instance Method Summary collapse

Instance Method Details

#sap(msg) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/super_awesome_print.rb', line 6

def sap(msg)
  SuperAwesomePrint.blank_lines_top
  ap "*** #{Time.now} ***", :color => { :string => :green }
  ap msg.class if msg.respond_to?(:class)
  SuperAwesomePrint.print_caller_lines(caller)
  ap msg
  ap '*** END ***', :color => { :string => :green }
  SuperAwesomePrint.blank_lines_bottom
  msg
end

#sapf(msg) ⇒ Object



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