44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/thread-dump.rb', line 44
def self.write_threads
out_arr = []
ThreadDump::Dumper.dump.each do |thread_info|
if ThreadDump::Config.output_format == :html
out_arr << "<dt>#{thread_info[1]}</dt><dd>#{thread_info[0]}</dd>"
else
out_arr << "Thread #{thread_info[0]}: #{thread_info[1]}"
end
end
max_l_out_arr = out_arr.map { |out| out.size }.max
fout = STDERR
if ThreadDump::Config.dump_target == :file
fout = File.open("/tmp/#{$$}.ruby_threads.html", "w")
end
out_arr.each do |out|
fout << "-" * max_l_out_arr + "\n" if ThreadDump::Config.output_format == :text
fout << out + "\n"
end
fout << "-" * max_l_out_arr + "\n" if ThreadDump::Config.output_format == :text
fout.flush
if fout != STDERR
fout.close
end
end
|