1 # This file was automatically generated by SWIG (http://www.swig.org).
4 # Don't modify this file, modify the SWIG interface instead.
6 package Amanda::Logfile;
9 @ISA = qw(Exporter DynaLoader);
10 require Amanda::Cmdline;
11 package Amanda::Logfilec;
12 bootstrap Amanda::Logfile;
13 package Amanda::Logfile;
16 # ---------- BASE METHODS -------------
18 package Amanda::Logfile;
21 my ($classname,$obj) = @_;
22 return bless $obj, $classname;
32 my ($self,$field) = @_;
33 my $member_func = "swig_${field}_get";
34 $self->$member_func();
38 my ($self,$field,$newval) = @_;
39 my $member_func = "swig_${field}_set";
40 $self->$member_func($newval);
49 # ------- FUNCTION WRAPPERS --------
51 package Amanda::Logfile;
53 *open_logfile = *Amanda::Logfilec::open_logfile;
54 *close_logfile = *Amanda::Logfilec::close_logfile;
55 *get_logline = *Amanda::Logfilec::get_logline;
56 *find_log = *Amanda::Logfilec::find_log;
57 *search_logfile = *Amanda::Logfilec::search_logfile;
58 *dumps_match = *Amanda::Logfilec::dumps_match;
59 *dumps_match_dumpspecs = *Amanda::Logfilec::dumps_match_dumpspecs;
61 ############# Class : Amanda::Logfile::find_result_t ##############
63 package Amanda::Logfile::find_result_t;
64 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
65 @ISA = qw( Amanda::Logfile );
69 return unless $_[0]->isa('HASH');
70 my $self = tied(%{$_[0]});
71 return unless defined $self;
72 delete $ITERATORS{$self};
73 if (exists $OWNER{$self}) {
74 Amanda::Logfilec::delete_find_result_t($self);
79 *swig_timestamp_get = *Amanda::Logfilec::find_result_t_timestamp_get;
80 *swig_timestamp_set = *Amanda::Logfilec::find_result_t_timestamp_set;
81 *swig_hostname_get = *Amanda::Logfilec::find_result_t_hostname_get;
82 *swig_hostname_set = *Amanda::Logfilec::find_result_t_hostname_set;
83 *swig_diskname_get = *Amanda::Logfilec::find_result_t_diskname_get;
84 *swig_diskname_set = *Amanda::Logfilec::find_result_t_diskname_set;
85 *swig_level_get = *Amanda::Logfilec::find_result_t_level_get;
86 *swig_level_set = *Amanda::Logfilec::find_result_t_level_set;
87 *swig_label_get = *Amanda::Logfilec::find_result_t_label_get;
88 *swig_label_set = *Amanda::Logfilec::find_result_t_label_set;
89 *swig_filenum_get = *Amanda::Logfilec::find_result_t_filenum_get;
90 *swig_filenum_set = *Amanda::Logfilec::find_result_t_filenum_set;
91 *swig_status_get = *Amanda::Logfilec::find_result_t_status_get;
92 *swig_status_set = *Amanda::Logfilec::find_result_t_status_set;
93 *swig_partnum_get = *Amanda::Logfilec::find_result_t_partnum_get;
94 *swig_partnum_set = *Amanda::Logfilec::find_result_t_partnum_set;
97 my $self = Amanda::Logfilec::new_find_result_t(@_);
98 bless $self, $pkg if defined($self);
103 my $ptr = tied(%$self);
109 my $ptr = tied(%$self);
114 # ------- VARIABLE STUBS --------
116 package Amanda::Logfile;
118 *L_BOGUS = *Amanda::Logfilec::L_BOGUS;
119 *L_FATAL = *Amanda::Logfilec::L_FATAL;
120 *L_ERROR = *Amanda::Logfilec::L_ERROR;
121 *L_WARNING = *Amanda::Logfilec::L_WARNING;
122 *L_INFO = *Amanda::Logfilec::L_INFO;
123 *L_SUMMARY = *Amanda::Logfilec::L_SUMMARY;
124 *L_START = *Amanda::Logfilec::L_START;
125 *L_FINISH = *Amanda::Logfilec::L_FINISH;
126 *L_DISK = *Amanda::Logfilec::L_DISK;
127 *L_DONE = *Amanda::Logfilec::L_DONE;
128 *L_PART = *Amanda::Logfilec::L_PART;
129 *L_PARTPARTIAL = *Amanda::Logfilec::L_PARTPARTIAL;
130 *L_SUCCESS = *Amanda::Logfilec::L_SUCCESS;
131 *L_PARTIAL = *Amanda::Logfilec::L_PARTIAL;
132 *L_FAIL = *Amanda::Logfilec::L_FAIL;
133 *L_STRANGE = *Amanda::Logfilec::L_STRANGE;
134 *L_CHUNK = *Amanda::Logfilec::L_CHUNK;
135 *L_CHUNKSUCCESS = *Amanda::Logfilec::L_CHUNKSUCCESS;
136 *L_STATS = *Amanda::Logfilec::L_STATS;
137 *L_MARKER = *Amanda::Logfilec::L_MARKER;
138 *L_CONT = *Amanda::Logfilec::L_CONT;
139 *P_UNKNOWN = *Amanda::Logfilec::P_UNKNOWN;
140 *P_PLANNER = *Amanda::Logfilec::P_PLANNER;
141 *P_DRIVER = *Amanda::Logfilec::P_DRIVER;
142 *P_REPORTER = *Amanda::Logfilec::P_REPORTER;
143 *P_DUMPER = *Amanda::Logfilec::P_DUMPER;
144 *P_CHUNKER = *Amanda::Logfilec::P_CHUNKER;
145 *P_TAPER = *Amanda::Logfilec::P_TAPER;
146 *P_AMFLUSH = *Amanda::Logfilec::P_AMFLUSH;
153 Amanda::Logfile - manage Amanda trace logs
157 use Amanda::Logfile qw(:logtype_t); # XXX change
158 use Amanda::Config qw( :getconf config_dir_relative );
160 for my $logfile (Amanda::Logfile::find_log()) {
161 $logfile = config_dir_relative(getconf($CNF_LOGDIR)) . "/" . $logfile;
163 my $hdl = Amanda::Logfile::open_logfile($logfile);
164 while (my ($type, $prog, $str) = Amanda::Logfile::get_logline($hdl)) {
165 if ($type == $L_INFO) {
166 my $pname = Amanda::Logfile::program_t_to_string($prog);
167 print "Found info line from $pname: $str\n";
170 Amanda::Logfile::close_logfile($log);
172 my @dumps = Amanda::Logfile::search_logfile("TapeLabel-001", "19780615", $logfile);
174 my @matching = Amanda::Logfile::dumps_match([@dumps], "myhost", "/usr", undef, undef, 0);
175 for my $dump (@matching) {
176 print "$dump->{'label'}:$dump->{'filenum'} = $dump->{'hostname'}:$dump->{'disk'}\n";
184 =head1 RAW LOGFILE ACCESS
186 This section corresponds to the C C<logfile> module.
188 Raw access to logfiles is accomplished by opening a logfile and
189 fetching log lines one by one via the C<get_logline> function.
191 A log line is represented by a list C<($type, $prog, $string)>
192 where C<$type> is one of the C<L_*> constants (available in export
193 tag C<logtype_t>), C<$prog> is one of the C<P_*> constants (available
194 in export tag C<program_t>), and C<$str> is the remainder of the line.
196 Both families of constants can be converted to symbolic names with
197 C<logtype_t_to_string> and C<program_t_to_string>, respectively.
203 =item C<open_logfile($filename)>
205 Opens a logfile for reading, returning an opaque log file handle.
207 =item C<close_logfile($handle)>
209 Closes a log file handle.
211 =item C<get_logline($handle)>
213 Return a list as described above representing the next log line in
214 C<$handle>, or nothing at the end of the logfile.
218 All of these functions can be imported by name if desired.
220 =head1 Amanda::Find::find_result_t objects
222 These objects contain information about dumps, as read from logfiles.
223 Instance variables are:
245 =head1 HIGHER-LEVEL FUNCTIONS
247 Functions in this section extract information from logfiles.
253 Return a list of logfiles for active tapes. The tapelist must be loaded before
254 this function is called (see L<Amanda::Tapelist>).
256 =item C<search_logfile($label, $datestamp, $logfile, $add_missing_disks)>
258 Return all results in C<$logfile> matching C<$label> and C<$datestamp>.
259 If C<$add_missing_disks> is true, then any disks in the logfile
260 not present in the disklist are added to the disklist; otherwise,
261 such dumps are skipped.
263 =item C<dumps_match([@results], $hostname, $diskname, $datestamp, $level, $ok)>
265 Return a filtered version of C<@results> containing only results that match the
266 given expressions. If C<$ok> is true, don't match partial results. Note that
267 C<$level> is given as a string, since it is a match expression.
269 All of these functions can be imported by name.
273 push @EXPORT_OK, qw(open_logfile get_logline close_logfile);
275 push @EXPORT_OK, qw(logtype_t_to_string);
276 push @{$EXPORT_TAGS{"logtype_t"}}, qw(logtype_t_to_string);
278 my %_logtype_t_VALUES;
279 #Convert an enum value to a single string
280 sub logtype_t_to_string {
283 for my $k (keys %_logtype_t_VALUES) {
284 my $v = $_logtype_t_VALUES{$k};
286 #is this a matching flag?
287 if ($enumval == $v) {
292 #default, just return the number
296 push @EXPORT_OK, qw($L_BOGUS);
297 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_BOGUS);
299 $_logtype_t_VALUES{"L_BOGUS"} = $L_BOGUS;
301 push @EXPORT_OK, qw($L_FATAL);
302 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_FATAL);
304 $_logtype_t_VALUES{"L_FATAL"} = $L_FATAL;
306 push @EXPORT_OK, qw($L_ERROR);
307 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_ERROR);
309 $_logtype_t_VALUES{"L_ERROR"} = $L_ERROR;
311 push @EXPORT_OK, qw($L_WARNING);
312 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_WARNING);
314 $_logtype_t_VALUES{"L_WARNING"} = $L_WARNING;
316 push @EXPORT_OK, qw($L_INFO);
317 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_INFO);
319 $_logtype_t_VALUES{"L_INFO"} = $L_INFO;
321 push @EXPORT_OK, qw($L_SUMMARY);
322 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_SUMMARY);
324 $_logtype_t_VALUES{"L_SUMMARY"} = $L_SUMMARY;
326 push @EXPORT_OK, qw($L_START);
327 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_START);
329 $_logtype_t_VALUES{"L_START"} = $L_START;
331 push @EXPORT_OK, qw($L_FINISH);
332 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_FINISH);
334 $_logtype_t_VALUES{"L_FINISH"} = $L_FINISH;
336 push @EXPORT_OK, qw($L_DISK);
337 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_DISK);
339 $_logtype_t_VALUES{"L_DISK"} = $L_DISK;
341 push @EXPORT_OK, qw($L_DONE);
342 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_DONE);
344 $_logtype_t_VALUES{"L_DONE"} = $L_DONE;
346 push @EXPORT_OK, qw($L_PART);
347 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_PART);
349 $_logtype_t_VALUES{"L_PART"} = $L_PART;
351 push @EXPORT_OK, qw($L_PARTPARTIAL);
352 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_PARTPARTIAL);
354 $_logtype_t_VALUES{"L_PARTPARTIAL"} = $L_PARTPARTIAL;
356 push @EXPORT_OK, qw($L_SUCCESS);
357 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_SUCCESS);
359 $_logtype_t_VALUES{"L_SUCCESS"} = $L_SUCCESS;
361 push @EXPORT_OK, qw($L_PARTIAL);
362 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_PARTIAL);
364 $_logtype_t_VALUES{"L_PARTIAL"} = $L_PARTIAL;
366 push @EXPORT_OK, qw($L_FAIL);
367 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_FAIL);
369 $_logtype_t_VALUES{"L_FAIL"} = $L_FAIL;
371 push @EXPORT_OK, qw($L_STRANGE);
372 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_STRANGE);
374 $_logtype_t_VALUES{"L_STRANGE"} = $L_STRANGE;
376 push @EXPORT_OK, qw($L_CHUNK);
377 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_CHUNK);
379 $_logtype_t_VALUES{"L_CHUNK"} = $L_CHUNK;
381 push @EXPORT_OK, qw($L_CHUNKSUCCESS);
382 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_CHUNKSUCCESS);
384 $_logtype_t_VALUES{"L_CHUNKSUCCESS"} = $L_CHUNKSUCCESS;
386 push @EXPORT_OK, qw($L_STATS);
387 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_STATS);
389 $_logtype_t_VALUES{"L_STATS"} = $L_STATS;
391 push @EXPORT_OK, qw($L_MARKER);
392 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_MARKER);
394 $_logtype_t_VALUES{"L_MARKER"} = $L_MARKER;
396 push @EXPORT_OK, qw($L_CONT);
397 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_CONT);
399 $_logtype_t_VALUES{"L_CONT"} = $L_CONT;
401 push @EXPORT_OK, qw(program_t_to_string);
402 push @{$EXPORT_TAGS{"program_t"}}, qw(program_t_to_string);
404 my %_program_t_VALUES;
405 #Convert an enum value to a single string
406 sub program_t_to_string {
409 for my $k (keys %_program_t_VALUES) {
410 my $v = $_program_t_VALUES{$k};
412 #is this a matching flag?
413 if ($enumval == $v) {
418 #default, just return the number
422 push @EXPORT_OK, qw($P_UNKNOWN);
423 push @{$EXPORT_TAGS{"program_t"}}, qw($P_UNKNOWN);
425 $_program_t_VALUES{"P_UNKNOWN"} = $P_UNKNOWN;
427 push @EXPORT_OK, qw($P_PLANNER);
428 push @{$EXPORT_TAGS{"program_t"}}, qw($P_PLANNER);
430 $_program_t_VALUES{"P_PLANNER"} = $P_PLANNER;
432 push @EXPORT_OK, qw($P_DRIVER);
433 push @{$EXPORT_TAGS{"program_t"}}, qw($P_DRIVER);
435 $_program_t_VALUES{"P_DRIVER"} = $P_DRIVER;
437 push @EXPORT_OK, qw($P_REPORTER);
438 push @{$EXPORT_TAGS{"program_t"}}, qw($P_REPORTER);
440 $_program_t_VALUES{"P_REPORTER"} = $P_REPORTER;
442 push @EXPORT_OK, qw($P_DUMPER);
443 push @{$EXPORT_TAGS{"program_t"}}, qw($P_DUMPER);
445 $_program_t_VALUES{"P_DUMPER"} = $P_DUMPER;
447 push @EXPORT_OK, qw($P_CHUNKER);
448 push @{$EXPORT_TAGS{"program_t"}}, qw($P_CHUNKER);
450 $_program_t_VALUES{"P_CHUNKER"} = $P_CHUNKER;
452 push @EXPORT_OK, qw($P_TAPER);
453 push @{$EXPORT_TAGS{"program_t"}}, qw($P_TAPER);
455 $_program_t_VALUES{"P_TAPER"} = $P_TAPER;
457 push @EXPORT_OK, qw($P_AMFLUSH);
458 push @{$EXPORT_TAGS{"program_t"}}, qw($P_AMFLUSH);
460 $_program_t_VALUES{"P_AMFLUSH"} = $P_AMFLUSH;
462 push @EXPORT_OK, qw(find_log search_logfile dumps_match);