[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stack Trace



sorry for the blank reply.  Trying again:


On Mon, May 19, 2014 at 8:50 PM, Chris Travers <..hidden..> wrote:



On Mon, May 19, 2014 at 2:19 PM, <..hidden..> wrote:
Dear Ledgersmb developers in order for me to debug applications I use a
what I call a 'stack trace'. To do this in Ledgersmb I have some code in
the beginning of every subroutine  like so:

if ( ${LedgerSMB::Sysconfig::debug} ) {
        open FILE, '>>', "../debug.txt";
        my $debug_sub  = ( caller(0) )[3],;
        my $debug_file = __FILE__,;
        $debug_sub =~ s/.*:://g;
        print FILE __FILE__, " sub $debug_sub Line: ", __LINE__, "\n";
        print FILE "Caller: ", caller, "\n\n";
        close FILE;
    }


Options, options, options....

If you need to do this, you can write Carp::longmess() instead.

However, better IMO is to use Carp::Always and warn().  That way when Carp::Always is loaded you get a full stack trace, and when it is not, you don't. 

Another option you can do is alter your log4perl configuration to log to a custom file, and add a %T to the layout pattern.  This would require very light patching to Sysconfig.pm (
log4perl.appender.Debug.layout.ConversionPattern = %d - %p - %l -- %m%n 
could get changed to
log4perl.appender.Debug.layout.ConversionPattern = %d - %p - %l -- %m%n %T %n
)

Maybe we should make the default configuration read from a log4perl configuration file to make it easier to change?

In Form.pm, User.pm or other frequently hit files I will add varying
levels if ( ${LedgerSMB::Sysconfig::debug} > 2 )

I end up with a file that steps through the program like so:
arap.pl 1310 continue
mainmenu.pl191

pe.pl  1138 sub project_report
mainbin/arap.pl1314
LedgerSMB/PE.pm sub projects Line: 45
Caller: mainbin/pe.pl1146

Is there any easier way to achieve this in 1.4?
Cheers
Turtle


------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ledger-smb-devel mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel



--
Best Wishes,
Chris Travers

Efficito:  Hosted Accounting and ERP.  Robust and Flexible.  No vendor lock-in.



--
Best Wishes,
Chris Travers

Efficito:  Hosted Accounting and ERP.  Robust and Flexible.  No vendor lock-in.
http://www.efficito.com/learn_more
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ledger-smb-devel mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel