paperlined.org
dev > perl > modules > documentation
document updated 7 days ago, on Apr 11, 2025
IMHO, Devel::DumpTrace is one of the best of the various trace tools.

sending trace to a log file

use within CGI scripts

Change the first line to be something like:
#!/usr/bin/perl -d:DumpTrace
Then add something like this near the very top of the script:
BEGIN {
    # if Devel::DumpTrace is loaded, direct output to the right log file
    if ( $INC{'Devel/DumpTrace.pm'} ) {
        open $Devel::DumpTrace::DUMPTRACE_FH, '>', '/tmp/DumpTrace.APPNAME.txt'
            or die "Unable to open dumptrace file: $!";
    }
}
TODO — NOTE that the above hasn't been tested yet.

viewing logs in Vim

This works for $Devel::DumpTrace::TRACE == 3.
:set nowrap                    " needed because some lines get OBNOXIOUSLY long
:match IncSearch /^[^>].*/     " make it easy to distinguish between DumpTrace lines and non

:" conceal
:syntax match NonText "^.\{-}:\d\+:\[[^\]]*\]:" conceal
:set conceallevel=2
:set concealcursor=nc       " concealed text is hidden, except for in visual mode

workaround for bug

When you try to load 'Devel::DumpTrace', then load and use 'DB_File', you get the error message:
DB_File::BTREEINFO does not define the method FIRSTKEY at /usr/local/share/perl5/Devel/DumpTrace.pm line 634.
A quick but non-functional workaround for this is to add this to your main script:
use DB_File;
BEGIN {
    # Silence the error "DB_File::BTREEINFO does not define the method FIRSTKEY" when using
    # Devel::DumpTrace, even though we don't actually fix the problem.
    *DB_File::HASHINFO::FIRSTKEY = *DB_File::HASHINFO::NEXTKEY = sub { };
}