/* * Copyright (c) Zmanda, Inc. All Rights Reserved. * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. * * This library 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 Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; 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 Mathlida Ave, Suite 300 * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com */ %module "Amanda::Logfile" %include "amglue/amglue.swg" %include "exception.i" %include "amglue/dumpspecs.swg" %import "Amanda/Cmdline.swg" %{ #include #include "logfile.h" #include "find.h" #include "diskfile.h" /* for the gross hack, below */ %} %perlcode %{ =head1 NAME Amanda::Logfile - manage Amanda trace logs =head1 SYNOPSIS use Amanda::Logfile qw(:logtype_t); use Amanda::Config qw( :getconf config_dir_relative ); for my $logfile (Amanda::Logfile::find_log()) { $logfile = config_dir_relative(getconf($CNF_LOGDIR)) . "/" . $logfile; my $hdl = Amanda::Logfile::open_logfile($logfile); while (my ($type, $prog, $str) = Amanda::Logfile::get_logline($hdl)) { if ($type == $L_INFO) { my $pname = Amanda::Logfile::program_t_to_string($prog); print "Found info line from $pname: $str\n"; } } Amanda::Logfile::close_logfile($log); my @dumps = Amanda::Logfile::search_logfile("TapeLabel-001", "19780615", $logfile, 1); my @matching = Amanda::Logfile::dumps_match([@dumps], "myhost", "/usr", undef, undef, 0); for my $dump (@matching) { print "$dump->{'label'}:$dump->{'filenum'} = $dump->{'hostname'}:$dump->{'disk'}\n"; } } =head1 API STATUS Stabilizing =head1 RAW LOGFILE ACCESS This section corresponds to the C C module. Raw access to logfiles is accomplished by opening a logfile and fetching log lines one by one via the C function. A log line is represented by a list C<($type, $prog, $string)> where C<$type> is one of the C constants (available in export tag C), C<$prog> is one of the C constants (available in export tag C), and C<$str> is the remainder of the line. Both families of constants can be converted to symbolic names with C and C, respectively. =head2 FUNCTIONS =over =item C Opens a logfile for reading, returning an opaque log file handle. =item C Closes a log file handle. =item C Return a list as described above representing the next log line in C<$handle>, or nothing at the end of the logfile. =back All of these functions can be imported by name if desired. =head1 Amanda::Find::find_result_t objects These objects contain information about dumps, as read from logfiles. Instance variables are: =over =item C =item C =item C =item C =item C