ad6795f942e17bad8a790419199ca72313d87d83
[debian/amanda] / perl / Amanda / Debug.pm
1 # This file was automatically generated by SWIG (http://www.swig.org).
2 # Version 1.3.33
3 #
4 # Don't modify this file, modify the SWIG interface instead.
5
6 package Amanda::Debug;
7 require Exporter;
8 require DynaLoader;
9 @ISA = qw(Exporter DynaLoader);
10 package Amanda::Debugc;
11 bootstrap Amanda::Debug;
12 package Amanda::Debug;
13 @EXPORT = qw( );
14
15 # ---------- BASE METHODS -------------
16
17 package Amanda::Debug;
18
19 sub TIEHASH {
20     my ($classname,$obj) = @_;
21     return bless $obj, $classname;
22 }
23
24 sub CLEAR { }
25
26 sub FIRSTKEY { }
27
28 sub NEXTKEY { }
29
30 sub FETCH {
31     my ($self,$field) = @_;
32     my $member_func = "swig_${field}_get";
33     $self->$member_func();
34 }
35
36 sub STORE {
37     my ($self,$field,$newval) = @_;
38     my $member_func = "swig_${field}_set";
39     $self->$member_func($newval);
40 }
41
42 sub this {
43     my $ptr = shift;
44     return tied(%$ptr);
45 }
46
47
48 # ------- FUNCTION WRAPPERS --------
49
50 package Amanda::Debug;
51
52 *dbopen = *Amanda::Debugc::dbopen;
53 *dbreopen = *Amanda::Debugc::dbreopen;
54 *dbrename = *Amanda::Debugc::dbrename;
55 *dbclose = *Amanda::Debugc::dbclose;
56 *error = *Amanda::Debugc::error;
57 *critical = *Amanda::Debugc::critical;
58 *warning = *Amanda::Debugc::warning;
59 *message = *Amanda::Debugc::message;
60 *info = *Amanda::Debugc::info;
61 *debug = *Amanda::Debugc::debug;
62 *dbfd = *Amanda::Debugc::dbfd;
63 *dbfn = *Amanda::Debugc::dbfn;
64 *debug_dup_stderr_to_debug = *Amanda::Debugc::debug_dup_stderr_to_debug;
65
66 # ------- VARIABLE STUBS --------
67
68 package Amanda::Debug;
69
70 *ERR_INTERACTIVE = *Amanda::Debugc::ERR_INTERACTIVE;
71 *ERR_SYSLOG = *Amanda::Debugc::ERR_SYSLOG;
72 *ERR_AMANDALOG = *Amanda::Debugc::ERR_AMANDALOG;
73 *erroutput_type = *Amanda::Debugc::erroutput_type;
74 *error_exit_status = *Amanda::Debugc::error_exit_status;
75
76 @EXPORT_OK = ();
77 %EXPORT_TAGS = ();
78
79 =head1 NAME
80
81 Amanda::Debug - support for debugging Amanda applications
82
83 =head1 SYNOPSIS
84
85   use Amanda::Debug qw( :init :logging );
86
87   # (note: dbopen and such are usually handled by 
88   #  Amanda::Util::setup_applicaton)
89   dbopen("server");
90
91   debug("this is a debug message");
92
93 See C<debug.h> for a more in-depth description of the functionality of
94 this module.
95
96 =head1 API STATUS
97
98 Stable
99
100 =head1 DEBUG LOGGING
101
102 Several debug logging messages, each taking a single string, are
103 available:
104
105 =over
106
107 =item C<error> - also aborts the program to produce a core dump
108
109 =item C<critical> - exits the program with C<$error_exit_status>
110
111 =item C<warning>
112
113 =item C<message>
114
115 =item C<info>
116
117 =item C<debug>
118
119 =back
120
121 ALl of the debug logging functions are available via the export tag
122 C<:logging>.
123
124 =head1 ADVANCED USAGE
125
126 Most applications should use L<Amanda::Util>'s C<setup_application>
127 to initialize the debug libraries.  The initialization functions
128 available from this module are thus considered "advanced", and the
129 reader is advised to consult the C header, C<debug.h>, for details.
130
131 Briefly, the functions C<dbopen> and C<dbrename> are used to
132 open a debug file whose pathname includes all of the relevant
133 information. C<dbclose> and C<dbreopen> are used to close that debug
134 file before transferring control to another process.
135
136 The variable C<$erroutput_type> can take on any combination
137 of the flags C<$ERROUTPUT_INTERACTIVE>, C<$ERROUTPUT_SYSLOG>
138 and C<$ERROUTPUT_AMANDALOG>.  C<$ERROUTPUT_INTERACTIVE>
139 causes messages from C<error> and C<critical> to be sent
140 to stderr. C<$ERROUTPUT_SYSLOG> sends it to syslog, and
141 C<$ERROUTPUT_AMANDALOG> sends it to the current trace log (see
142 L<Amanda::Logfile>).
143
144 C<$error_exit_status> is the exit status with which C<critical>
145 will exit.
146
147 All of the initialization functions and variables are available via
148 the export tag C<:init>.
149
150 The current debug file's integer file descriptor (I<not> a Perl
151 filehandle) is available from C<dbfd()>.  Likewise, C<dbfn()> returns
152 the filename of the current debug file.
153
154 C<debug_dup_stderr_to_debug()> redirects, at the file-descriptor level,
155 C<STDERR> into the debug file.  This is useful when running external
156 applications which may produce error output.
157
158 =cut
159
160 push @EXPORT_OK, qw(dbopen dbreopen dbrename dbclose
161     $erroutput_type $error_exit_status);
162 push @{$EXPORT_TAGS{"init"}}, qw(dbopen dbreopen dbrename dbclose
163     $erroutput_type $error_exit_status);
164
165 push @EXPORT_OK, qw(erroutput_type_t_to_strings);
166 push @{$EXPORT_TAGS{"erroutput_type_t"}}, qw(erroutput_type_t_to_strings);
167
168 my %_erroutput_type_t_VALUES;
169 #Convert a flag value to a list of names for flags that are set.
170 sub erroutput_type_t_to_strings {
171     my ($flags) = @_;
172     my @result = ();
173
174     for my $k (keys %_erroutput_type_t_VALUES) {
175         my $v = $_erroutput_type_t_VALUES{$k};
176
177         #is this a matching flag?
178         if (($v == 0 && $flags == 0) || ($v != 0 && ($flags & $v) == $v)) {
179             push @result, $k;
180         }
181     }
182
183 #by default, just return the number as a 1-element list
184     if (!@result) {
185         return ($flags);
186     }
187
188     return @result;
189 }
190
191 push @EXPORT_OK, qw($ERR_INTERACTIVE);
192 push @{$EXPORT_TAGS{"erroutput_type_t"}}, qw($ERR_INTERACTIVE);
193
194 $_erroutput_type_t_VALUES{"INTERACTIVE"} = $ERR_INTERACTIVE;
195
196 push @EXPORT_OK, qw($ERR_SYSLOG);
197 push @{$EXPORT_TAGS{"erroutput_type_t"}}, qw($ERR_SYSLOG);
198
199 $_erroutput_type_t_VALUES{"SYSLOG"} = $ERR_SYSLOG;
200
201 push @EXPORT_OK, qw($ERR_AMANDALOG);
202 push @{$EXPORT_TAGS{"erroutput_type_t"}}, qw($ERR_AMANDALOG);
203
204 $_erroutput_type_t_VALUES{"AMANDALOG"} = $ERR_AMANDALOG;
205
206 push @EXPORT_OK, qw(error critical warning message info debug);
207 push @{$EXPORT_TAGS{"logging"}}, qw(error critical warning message info debug);
208 1;