/* * Copyright (c) 2009-2012 Zmanda, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com */ %perlcode %{ =head1 NAME Amanda::Debug - support for debugging Amanda applications =head1 SYNOPSIS use Amanda::Util qw( :constants ); Amanda::Util::setup_application("amcooltool", "server", $CONTEXT_CMDLINE); debug("this is a debug message"); die("Unable to frobnicate the ergonator"); See C for a more in-depth description of the logging functionality of this module. =head1 DEBUG LOGGING Several debug logging functions, each taking a single string, are available: =over =item C - also aborts the program to produce a core dump =item C - exits the program with C<$error_exit_status> =item C =item C =item C =item C =back Perl's built-in C and C functions are patched to call C and C, respectively. All of the debug logging functions are available via the export tag C<:logging>. Applications can adjust the handling of log messages with C where C<$hdlr> is a predefined log destination. The following destinations are available in this package. See L for C<$amanda_log_trace_log>. $amanda_log_null $amanda_log_stderr $amanda_log_syslog =head1 ADVANCED USAGE Most applications should use L's C to initialize the debug libraries. The initialization functions available from this module are thus considered "advanced", and the reader is advised to consult the C header, C, for details. Briefly, the functions C and C are used to open a debug file whose pathname includes all of the relevant information. C and C are used to close that debug file before transferring control to another process. C<$error_exit_status> is the exit status with which C will exit. All of the initialization functions and variables are available via the export tag C<:init>. The current debug file's integer file descriptor (I a Perl filehandle) is available from C. Likewise, C returns the filename of the current debug file. C redirects, at the file-descriptor level, C into the debug file. This is useful when running external applications which may produce error output. =cut %}