1 # This file was automatically generated by SWIG (http://www.swig.org).
4 # Do not make changes to this file unless you know what you are doing--modify
5 # the SWIG interface file instead.
9 use base qw(DynaLoader);
10 package Amanda::Debugc;
11 bootstrap Amanda::Debug;
12 package Amanda::Debug;
15 # ---------- BASE METHODS -------------
17 package Amanda::Debug;
20 my ($classname,$obj) = @_;
21 return bless $obj, $classname;
31 my ($self,$field) = @_;
32 my $member_func = "swig_${field}_get";
33 $self->$member_func();
37 my ($self,$field,$newval) = @_;
38 my $member_func = "swig_${field}_set";
39 $self->$member_func($newval);
48 # ------- FUNCTION WRAPPERS --------
50 package Amanda::Debug;
52 *debug_init = *Amanda::Debugc::debug_init;
53 *dbopen = *Amanda::Debugc::dbopen;
54 *dbreopen = *Amanda::Debugc::dbreopen;
55 *dbrename = *Amanda::Debugc::dbrename;
56 *dbclose = *Amanda::Debugc::dbclose;
57 *error = *Amanda::Debugc::error;
58 *critical = *Amanda::Debugc::critical;
59 *warning = *Amanda::Debugc::warning;
60 *message = *Amanda::Debugc::message;
61 *info = *Amanda::Debugc::info;
62 *debug = *Amanda::Debugc::debug;
63 *add_amanda_log_handler = *Amanda::Debugc::add_amanda_log_handler;
64 *suppress_error_traceback = *Amanda::Debugc::suppress_error_traceback;
65 *dbfd = *Amanda::Debugc::dbfd;
66 *dbfn = *Amanda::Debugc::dbfn;
67 *debug_dup_stderr_to_debug = *Amanda::Debugc::debug_dup_stderr_to_debug;
69 # ------- VARIABLE STUBS --------
71 package Amanda::Debug;
73 *error_exit_status = *Amanda::Debugc::error_exit_status;
74 *amanda_log_stderr = *Amanda::Debugc::amanda_log_stderr;
75 *amanda_log_syslog = *Amanda::Debugc::amanda_log_syslog;
76 *amanda_log_null = *Amanda::Debugc::amanda_log_null;
84 Amanda::Debug - support for debugging Amanda applications
88 use Amanda::Util qw( :constants );
90 Amanda::Util::setup_application("amcooltool", "server", $CONTEXT_CMDLINE);
92 debug("this is a debug message");
93 die("Unable to frobnicate the ergonator");
95 See C<debug.h> for a more in-depth description of the logging
96 functionality of this module.
100 Several debug logging functions, each taking a single string, are
105 =item C<error> - also aborts the program to produce a core dump
107 =item C<critical> - exits the program with C<$error_exit_status>
119 Perl's built-in C<die> and C<warn> functions are patched to call
120 C<critical> and C<warning>, respectively.
122 All of the debug logging functions are available via the export tag
125 Applications can adjust the handling of log messages with
126 C<add_amanda_log_handler($hdlr)> where C<$hdlr> is a predefined log
127 destination. The following destinations are available in this
128 package. See L<Amanda::Logfile> for C<$amanda_log_trace_log>.
134 =head1 ADVANCED USAGE
136 Most applications should use L<Amanda::Util>'s C<setup_application> to
137 initialize the debug libraries. The initialization functions
138 available from this module are thus considered "advanced", and the
139 reader is advised to consult the C header, C<debug.h>, for details.
141 Briefly, the functions C<dbopen> and C<dbrename> are used to open a
142 debug file whose pathname includes all of the relevant
143 information. C<dbclose> and C<dbreopen> are used to close that debug
144 file before transferring control to another process.
146 C<$error_exit_status> is the exit status with which C<critical> will
149 All of the initialization functions and variables are available via
150 the export tag C<:init>.
152 The current debug file's integer file descriptor (I<not> a Perl
153 filehandle) is available from C<dbfd()>. Likewise, C<dbfn()> returns
154 the filename of the current debug file.
156 C<debug_dup_stderr_to_debug()> redirects, at the file-descriptor
157 level, C<STDERR> into the debug file. This is useful when running
158 external applications which may produce error output.
164 push @EXPORT_OK, qw(debug_init dbopen dbreopen dbrename dbclose
166 push @{$EXPORT_TAGS{"init"}}, qw(debug_init dbopen dbreopen dbrename dbclose
170 # $^S: (from perlvar)
171 # undef -> parsing module/eval
172 # 1 -> executing an eval
174 # we *only* want to call critical() in the "otherwise" case
175 if (!defined($^S) or $^S == 1) {
180 suppress_error_traceback();
184 $SIG{__DIE__} = \&_my_die;
191 $SIG{__WARN__} = \&_my_warn;
193 # utility function for test scripts, which want to use the regular
195 sub disable_die_override {
196 delete $SIG{__DIE__};
197 delete $SIG{__WARN__};
200 push @EXPORT_OK, qw(error critical warning message info debug);
201 push @{$EXPORT_TAGS{"logging"}}, qw(error critical warning message info debug);
203 push @EXPORT_OK, qw(add_amanda_log_handler
204 $amanda_log_stderr $amanda_log_syslog $amanda_log_null);
205 push @{$EXPORT_TAGS{"logging"}}, qw(add_amanda_log_handler
206 $amanda_log_stderr $amanda_log_syslog $amanda_log_null);