[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

log a stack trace

aidy

8/26/2008 10:32:00 AM

Hi,

Is it possible to log a stack trace to a text file?

Thanks

Aidy
2 Answers

Lars Christensen

8/26/2008 11:02:00 AM

0

On Aug 26, 12:32 pm, aidy <aidy.le...@googlemail.com> wrote:
> Is it possible to log a stack trace to a text file?

Yes: Raise an exception.

def backtrace
begin
fail
rescue Exception => e
return e.backtrace[1..-1]
end
end

File.open("backtrace.txt", "w") do |f|
f.puts backtrace
end

Lars

TPReal

8/26/2008 12:20:00 PM

0

aidy wrote:
> Hi,
>
> Is it possible to log a stack trace to a text file?
>
> Thanks
>
> Aidy

File::open("file","w"){|f| f<<caller.join("\n")}
--
Posted via http://www.ruby-....