Module: MongrelDbg

Defined in:
lib/mongrel/debug.rb

Constant Summary collapse

SETTINGS =
{ :tracing => {}}
LOGGING =
{ }

Class Method Summary collapse

Class Method Details

.begin_trace(target) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/mongrel/debug.rb', line 33

def MongrelDbg::begin_trace(target)
  SETTINGS[:tracing][target] = true
  if not LOGGING[target]
    LOGGING[target] = Logger.new(File.join(@log_dir, "#{target.to_s}.log"))
  end                          
  MongrelDbg::trace(target, "TRACING ON #{Time.now}")
end

.configure(log_dir = File.join("log","mongrel_debug")) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/mongrel/debug.rb', line 16

def MongrelDbg::configure(log_dir = File.join("log","mongrel_debug"))
  FileUtils.mkdir_p(log_dir)
  @log_dir = log_dir
  $objects_out=open(File.join("log","mongrel_debug","objects.log"),"w")
  $objects_out.puts "run,classname,last,count,delta,lenmean,lensd,lenmax"
  $objects_out.sync = true
  $last_stat = nil
  $run_count = 0
end

.end_trace(target) ⇒ Object



41
42
43
44
45
46
# File 'lib/mongrel/debug.rb', line 41

def MongrelDbg::end_trace(target)
  SETTINGS[:tracing][target] = false
  MongrelDbg::trace(target, "TRACING OFF #{Time.now}")
  LOGGING[target].close
  LOGGING[target] = nil
end

.trace(target, message) ⇒ Object



27
28
29
30
31
# File 'lib/mongrel/debug.rb', line 27

def MongrelDbg::trace(target, message)
  if SETTINGS[:tracing][target] and LOGGING[target]
    LOGGING[target].log(Logger::DEBUG, message)
  end
end

.tracing?(target) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/mongrel/debug.rb', line 48

def MongrelDbg::tracing?(target)
  SETTINGS[:tracing][target]
end