Module: Kiss::Debug

Defined in:
lib/kiss/debug.rb

Overview

Generates HTML reports on exceptions raised from the app, showing the backtrace with clickable stack frames with TextMate links to source files, plus login hash, last SQL, GET/POST params, cookies, and Rack environment variables.

Instance Method Summary collapse

Instance Method Details

#prepend_debug(document) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/kiss/debug.rb', line 7

def prepend_debug(document)
  html = <<-EOT
<style>
.kiss_debug {
text-align: left;
padding: 3px 7px;
border: 1px solid #ebe;
border-top: 1px solid #fdf;
border-bottom: 1px solid #d6d;
background-color: #fbf;
font-size: 12px;
color: #101;
}
.kiss_debug a {
color: #606;
text-decoration: none;
}
.kiss_debug a:hover {
color: #707;
text-decoration: underline;
}
.kiss_debug small {
  font-family: arial, sans-serif;
  color: #949;
  float: right;
  margin-left: 8px;
  text-align: right;
  white-space: nowrap;
}
</style>
EOT
  html += @_debug_messages.map do |object, context|
    filename, line, method = context.split(/:/)
    textmate_url = "txmt://open?url=file://" + Kiss.absolute_path(filename).url_escape + '&line=' + line
    <<-EOT
<div class="kiss_debug">
<small>kiss debug at <a href="#{textmate_url}">#{filename}:#{line}</a> #{method}</small>
<tt><b>#{object.gsub(/\</, '&lt;')}</b></tt>
</div>
EOT
  end.join
  
  document.prepend_html(html, 'body')
end