/usr/lib/amanda/perl/Amanda/Debug.pm is in amanda-common 1:3.3.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | # This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.4
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
package Amanda::Debug;
use base qw(Exporter);
use base qw(DynaLoader);
package Amanda::Debugc;
bootstrap Amanda::Debug;
package Amanda::Debug;
@EXPORT = qw();
# ---------- BASE METHODS -------------
package Amanda::Debug;
sub TIEHASH {
my ($classname,$obj) = @_;
return bless $obj, $classname;
}
sub CLEAR { }
sub FIRSTKEY { }
sub NEXTKEY { }
sub FETCH {
my ($self,$field) = @_;
my $member_func = "swig_${field}_get";
$self->$member_func();
}
sub STORE {
my ($self,$field,$newval) = @_;
my $member_func = "swig_${field}_set";
$self->$member_func($newval);
}
sub this {
my $ptr = shift;
return tied(%$ptr);
}
# ------- FUNCTION WRAPPERS --------
package Amanda::Debug;
*debug_init = *Amanda::Debugc::debug_init;
*dbopen = *Amanda::Debugc::dbopen;
*dbreopen = *Amanda::Debugc::dbreopen;
*dbrename = *Amanda::Debugc::dbrename;
*dbclose = *Amanda::Debugc::dbclose;
*error = *Amanda::Debugc::error;
*critical = *Amanda::Debugc::critical;
*warning = *Amanda::Debugc::warning;
*message = *Amanda::Debugc::message;
*info = *Amanda::Debugc::info;
*debug = *Amanda::Debugc::debug;
*add_amanda_log_handler = *Amanda::Debugc::add_amanda_log_handler;
*suppress_error_traceback = *Amanda::Debugc::suppress_error_traceback;
*dbfd = *Amanda::Debugc::dbfd;
*dbfn = *Amanda::Debugc::dbfn;
*debug_dup_stderr_to_debug = *Amanda::Debugc::debug_dup_stderr_to_debug;
# ------- VARIABLE STUBS --------
package Amanda::Debug;
*error_exit_status = *Amanda::Debugc::error_exit_status;
*amanda_log_stderr = *Amanda::Debugc::amanda_log_stderr;
*amanda_log_syslog = *Amanda::Debugc::amanda_log_syslog;
*amanda_log_null = *Amanda::Debugc::amanda_log_null;
@EXPORT_OK = ();
%EXPORT_TAGS = ();
=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<debug.h> 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<error> - also aborts the program to produce a core dump
=item C<critical> - exits the program with C<$error_exit_status>
=item C<warning>
=item C<message>
=item C<info>
=item C<debug>
=back
Perl's built-in C<die> and C<warn> functions are patched to call
C<critical> and C<warning>, 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<add_amanda_log_handler($hdlr)> where C<$hdlr> is a predefined log
destination. The following destinations are available in this
package. See L<Amanda::Logfile> for C<$amanda_log_trace_log>.
$amanda_log_null
$amanda_log_stderr
$amanda_log_syslog
=head1 ADVANCED USAGE
Most applications should use L<Amanda::Util>'s C<setup_application> 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<debug.h>, for details.
Briefly, the functions C<dbopen> and C<dbrename> are used to open a
debug file whose pathname includes all of the relevant
information. C<dbclose> and C<dbreopen> are used to close that debug
file before transferring control to another process.
C<$error_exit_status> is the exit status with which C<critical> 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<not> a Perl
filehandle) is available from C<dbfd()>. Likewise, C<dbfn()> returns
the filename of the current debug file.
C<debug_dup_stderr_to_debug()> redirects, at the file-descriptor
level, C<STDERR> into the debug file. This is useful when running
external applications which may produce error output.
=cut
push @EXPORT_OK, qw(debug_init dbopen dbreopen dbrename dbclose
$error_exit_status);
push @{$EXPORT_TAGS{"init"}}, qw(debug_init dbopen dbreopen dbrename dbclose
$error_exit_status);
sub _my_die {
# $^S: (from perlvar)
# undef -> parsing module/eval
# 1 -> executing an eval
# 0 -> otherwise
# we *only* want to call critical() in the "otherwise" case
if (!defined($^S) or $^S == 1) {
die(@_);
} else {
my ($msg) = @_;
chomp $msg;
suppress_error_traceback();
critical(@_);
}
};
$SIG{__DIE__} = \&_my_die;
sub _my_warn {
my ($msg) = @_;
chomp $msg;
warning(@_);
};
$SIG{__WARN__} = \&_my_warn;
# utility function for test scripts, which want to use the regular
# perl mechanisms
sub disable_die_override {
delete $SIG{__DIE__};
delete $SIG{__WARN__};
}
push @EXPORT_OK, qw(error critical warning message info debug);
push @{$EXPORT_TAGS{"logging"}}, qw(error critical warning message info debug);
push @EXPORT_OK, qw(add_amanda_log_handler
$amanda_log_stderr $amanda_log_syslog $amanda_log_null);
push @{$EXPORT_TAGS{"logging"}}, qw(add_amanda_log_handler
$amanda_log_stderr $amanda_log_syslog $amanda_log_null);
1;
|