log a stack trace

Discussion in 'Ruby' started by aidy, Aug 26, 2008.

  1. aidy

    aidy Guest

    Hi,

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

    Thanks

    Aidy
     
    aidy, Aug 26, 2008
    #1
    1. Advertising

  2. On Aug 26, 12:32 pm, aidy <> 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
     
    Lars Christensen, Aug 26, 2008
    #2
    1. Advertising

  3. aidy

    Thomas B. Guest

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


    File::eek:pen("file","w"){|f| f<<caller.join("\n")}
    --
    Posted via http://www.ruby-forum.com/.
     
    Thomas B., Aug 26, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rukmal Fernando
    Replies:
    4
    Views:
    892
    Richard Grimes [MVP]
    Oct 27, 2003
  2. Matthias S.
    Replies:
    1
    Views:
    686
    Daniel Fisher\(lennybacon\)
    Nov 30, 2005
  3. Jiho Han
    Replies:
    0
    Views:
    557
    Jiho Han
    Aug 22, 2006
  4. Baron Samedi
    Replies:
    9
    Views:
    350
    Baron Samedi
    Jan 23, 2007
  5. =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=

    Adding my messages to the trace.axd trace?

    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=, Apr 6, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    622
    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=
    Apr 6, 2007
Loading...

Share This Page