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.
7 package Amanda::Logfile;
9 use base qw(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 *log_add = *Amanda::Logfilec::log_add;
57 *log_add_full = *Amanda::Logfilec::log_add_full;
58 *log_rename = *Amanda::Logfilec::log_rename;
59 *find_log = *Amanda::Logfilec::find_log;
60 *search_logfile = *Amanda::Logfilec::search_logfile;
61 *search_holding_disk = *Amanda::Logfilec::search_holding_disk;
62 *dumps_match = *Amanda::Logfilec::dumps_match;
63 *dumps_match_dumpspecs = *Amanda::Logfilec::dumps_match_dumpspecs;
64 *match_host = *Amanda::Logfilec::match_host;
65 *match_disk = *Amanda::Logfilec::match_disk;
66 *match_datestamp = *Amanda::Logfilec::match_datestamp;
67 *match_level = *Amanda::Logfilec::match_level;
69 ############# Class : Amanda::Logfile::find_result_t ##############
71 package Amanda::Logfile::find_result_t;
72 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
73 @ISA = qw( Amanda::Logfile );
77 return unless $_[0]->isa('HASH');
78 my $self = tied(%{$_[0]});
79 return unless defined $self;
80 delete $ITERATORS{$self};
81 if (exists $OWNER{$self}) {
82 Amanda::Logfilec::delete_find_result_t($self);
87 *swig_timestamp_get = *Amanda::Logfilec::find_result_t_timestamp_get;
88 *swig_timestamp_set = *Amanda::Logfilec::find_result_t_timestamp_set;
89 *swig_write_timestamp_get = *Amanda::Logfilec::find_result_t_write_timestamp_get;
90 *swig_write_timestamp_set = *Amanda::Logfilec::find_result_t_write_timestamp_set;
91 *swig_hostname_get = *Amanda::Logfilec::find_result_t_hostname_get;
92 *swig_hostname_set = *Amanda::Logfilec::find_result_t_hostname_set;
93 *swig_diskname_get = *Amanda::Logfilec::find_result_t_diskname_get;
94 *swig_diskname_set = *Amanda::Logfilec::find_result_t_diskname_set;
95 *swig_level_get = *Amanda::Logfilec::find_result_t_level_get;
96 *swig_level_set = *Amanda::Logfilec::find_result_t_level_set;
97 *swig_label_get = *Amanda::Logfilec::find_result_t_label_get;
98 *swig_label_set = *Amanda::Logfilec::find_result_t_label_set;
99 *swig_filenum_get = *Amanda::Logfilec::find_result_t_filenum_get;
100 *swig_filenum_set = *Amanda::Logfilec::find_result_t_filenum_set;
101 *swig_status_get = *Amanda::Logfilec::find_result_t_status_get;
102 *swig_status_set = *Amanda::Logfilec::find_result_t_status_set;
103 *swig_dump_status_get = *Amanda::Logfilec::find_result_t_dump_status_get;
104 *swig_dump_status_set = *Amanda::Logfilec::find_result_t_dump_status_set;
105 *swig_message_get = *Amanda::Logfilec::find_result_t_message_get;
106 *swig_message_set = *Amanda::Logfilec::find_result_t_message_set;
107 *swig_partnum_get = *Amanda::Logfilec::find_result_t_partnum_get;
108 *swig_partnum_set = *Amanda::Logfilec::find_result_t_partnum_set;
109 *swig_totalparts_get = *Amanda::Logfilec::find_result_t_totalparts_get;
110 *swig_totalparts_set = *Amanda::Logfilec::find_result_t_totalparts_set;
111 *swig_sec_get = *Amanda::Logfilec::find_result_t_sec_get;
112 *swig_sec_set = *Amanda::Logfilec::find_result_t_sec_set;
113 *swig_bytes_get = *Amanda::Logfilec::find_result_t_bytes_get;
114 *swig_bytes_set = *Amanda::Logfilec::find_result_t_bytes_set;
115 *swig_kb_get = *Amanda::Logfilec::find_result_t_kb_get;
116 *swig_kb_set = *Amanda::Logfilec::find_result_t_kb_set;
117 *swig_orig_kb_get = *Amanda::Logfilec::find_result_t_orig_kb_get;
118 *swig_orig_kb_set = *Amanda::Logfilec::find_result_t_orig_kb_set;
121 my $self = Amanda::Logfilec::new_find_result_t(@_);
122 bless $self, $pkg if defined($self);
127 my $ptr = tied(%$self);
133 my $ptr = tied(%$self);
138 # ------- VARIABLE STUBS --------
140 package Amanda::Logfile;
142 *L_BOGUS = *Amanda::Logfilec::L_BOGUS;
143 *L_FATAL = *Amanda::Logfilec::L_FATAL;
144 *L_ERROR = *Amanda::Logfilec::L_ERROR;
145 *L_WARNING = *Amanda::Logfilec::L_WARNING;
146 *L_INFO = *Amanda::Logfilec::L_INFO;
147 *L_SUMMARY = *Amanda::Logfilec::L_SUMMARY;
148 *L_START = *Amanda::Logfilec::L_START;
149 *L_FINISH = *Amanda::Logfilec::L_FINISH;
150 *L_DISK = *Amanda::Logfilec::L_DISK;
151 *L_DONE = *Amanda::Logfilec::L_DONE;
152 *L_PART = *Amanda::Logfilec::L_PART;
153 *L_PARTPARTIAL = *Amanda::Logfilec::L_PARTPARTIAL;
154 *L_SUCCESS = *Amanda::Logfilec::L_SUCCESS;
155 *L_PARTIAL = *Amanda::Logfilec::L_PARTIAL;
156 *L_FAIL = *Amanda::Logfilec::L_FAIL;
157 *L_STRANGE = *Amanda::Logfilec::L_STRANGE;
158 *L_CHUNK = *Amanda::Logfilec::L_CHUNK;
159 *L_CHUNKSUCCESS = *Amanda::Logfilec::L_CHUNKSUCCESS;
160 *L_STATS = *Amanda::Logfilec::L_STATS;
161 *L_MARKER = *Amanda::Logfilec::L_MARKER;
162 *L_CONT = *Amanda::Logfilec::L_CONT;
163 *P_UNKNOWN = *Amanda::Logfilec::P_UNKNOWN;
164 *P_PLANNER = *Amanda::Logfilec::P_PLANNER;
165 *P_DRIVER = *Amanda::Logfilec::P_DRIVER;
166 *P_REPORTER = *Amanda::Logfilec::P_REPORTER;
167 *P_DUMPER = *Amanda::Logfilec::P_DUMPER;
168 *P_CHUNKER = *Amanda::Logfilec::P_CHUNKER;
169 *P_TAPER = *Amanda::Logfilec::P_TAPER;
170 *P_AMFLUSH = *Amanda::Logfilec::P_AMFLUSH;
171 *P_AMDUMP = *Amanda::Logfilec::P_AMDUMP;
172 *P_AMIDXTAPED = *Amanda::Logfilec::P_AMIDXTAPED;
173 *P_AMFETCHDUMP = *Amanda::Logfilec::P_AMFETCHDUMP;
174 *P_AMCHECKDUMP = *Amanda::Logfilec::P_AMCHECKDUMP;
175 *P_AMVAULT = *Amanda::Logfilec::P_AMVAULT;
176 *amanda_log_trace_log = *Amanda::Logfilec::amanda_log_trace_log;
184 Amanda::Logfile - manage Amanda trace logs
188 use Amanda::Logfile qw( :constants );
189 use Amanda::Config qw( :getconf config_dir_relative );
191 for my $logfile (Amanda::Logfile::find_log()) {
192 $logfile = config_dir_relative(getconf($CNF_LOGDIR)) . "/" . $logfile;
194 my $hdl = Amanda::Logfile::open_logfile($logfile);
195 while (my ($type, $prog, $str) = Amanda::Logfile::get_logline($hdl)) {
196 if ($type == $L_INFO) {
197 my $pname = Amanda::Logfile::program_t_to_string($prog);
198 print "Found info line from $pname: $str\n";
201 Amanda::Logfile::close_logfile($hdl);
203 my @dumps = Amanda::Logfile::search_logfile("TapeLabel-001", "19780615", $logfile, 1);
205 my @matching = Amanda::Logfile::dumps_match([@dumps], "myhost", "/usr", undef, undef, 0);
206 for my $dump (@matching) {
207 print "$dump->{'label'}:$dump->{'filenum'} = $dump->{'hostname'}:$dump->{'disk'}\n";
211 =head1 RAW LOGFILE ACCESS
213 This section corresponds to the C C<logfile> module.
215 Raw access to logfiles is accomplished by opening a logfile and
216 fetching log lines one by one via the C<get_logline> function.
218 A log line is represented by a list C<($type, $prog, $string)> where C<$type>
219 is one of the C<L_*> constants (available in export tag C<logtype_t>), C<$prog>
220 is one of the C<P_*> constants (available in export tag C<program_t>), and
221 C<$str> is the remainder of the line. Both sets of constants are also available
222 in the usual C<constants> export tag. Both families of constants can be
223 converted to symbolic names with C<logtype_t_to_string> and
224 C<program_t_to_string>, respectively.
228 Use these functions to read a logfile:
232 =item C<open_logfile($filename)>
234 Opens a logfile for reading, returning an opaque log file
235 handle. Returns C<undef> and sets C<$!> on failure.
237 =item C<close_logfile($handle)>
239 Closes a log file handle.
241 =item C<get_logline($handle)>
243 Returns a list as described above representing the next log line in
244 C<$handle>, or nothing at the end of the logfile.
248 =head3 Writing a "current" Logfile
250 To write a logfile, call C<log_add($logtype, $string)>. On the first call,
251 this function opens and locks C<$logdir/log>; subsequent calls just append to
252 this file. As such, this function is only appropriate for situations where
253 C<log_rename> will be invoked later to rename C<$logdir/log> to
254 C<$logdir/log.$timestamp.$n>.
256 If you need to write a log entry for another program, for example to simulate
257 taper entries, call C<log_add_full($logtype, $pname, $string)>.
259 All of the functions in this section can be imported by name if
264 Many trace log entries have a statistics entry in what used to be the error
265 message slot, of the form C<[sec .. kb .. kps ..]>. The function C<make_stats>
266 will create such an entry for you:
268 make_stats($size, $duration, $orig_kb);
270 Note that C<$orig_kb> can be undefined, in which case it will not appear in
271 the statistics output.
273 =head2 Amanda::Find::find_result_t objects
275 These objects contain information about dumps, as read from logfiles.
276 Instance variables are:
278 To rename the current logfile to a datestamped logfile, call C<log_rename($ts)>
279 where C<$ts> is the write timestamp for this dump. The
280 C<get_current_log_timestamp()> function will calculate this timestamp,
281 returning C<undef> on error.
309 Note that the format for these variables are based on that found in
310 the logfiles. In particular, C<timestamp> is the timestamp for the run
311 in which the client dump took place, and not for the timestamp of the
314 =head1 HIGHER-LEVEL FUNCTIONS
316 Functions in this section extract information from logfiles.
322 Return a list of logfiles for active tapes. The tapelist must be loaded
323 before this function is called (see L<Amanda::Tapelist>). This function uses
324 the C API which indexes logfiles with tapes. If there is no corresponding
325 tape, the logfile will not be found.
327 =item C<find_all_logs([dir])>
329 Return a list of all logs the configuration. An optional directory argument
330 can be specified, if not present, C<find_all_logs> checks C<LOGDIR>.
332 =item C<find_latest_log([dir])>
334 Returns the most recent logfile in the list of logfiles returned by
335 C<find_all_logs>. The optional directory argument is passed to
338 =item C<search_logfile($label, $datestamp, $logfile, $add_missing_disks)>
340 Return all results in C<$logfile> matching C<$label> and
341 C<$datestamp>. If C<$add_missing_disks> is true, then any disks in
342 the logfile not present in the disklist are added to the disklist;
343 otherwise, such dumps are skipped.
345 =item C<search_holding_disk()>
347 Return results for all holding-disk files. Results are similar to those from
350 =item C<dumps_match([@results], $hostname, $diskname, $datestamp, $level, $ok)>
352 Return a filtered version of C<@results> containing only results that
353 match the given expressions. If C<$ok> is true, don't match partial
354 results. Note that C<$level> is given as a string, since it is a
357 =item C<dumps_match_dumpspecs([@results], [@dumpspecs], $ok)>
359 Return a filtered version of C<@results>, containing only results that match
360 one or more of the dumpspecs. C<$ok> is as for C<dumps_match>. Supplying no
361 dumpspecs will result in an empty return value. If multiple dumpspecs match
362 the same result, that result will be returned multiple times.
366 All of these functions can be imported by name.
370 The following functions are available to match strings against patterns using
371 the rules described in amanda(8):
373 match_host($pat, $str);
374 match_disk($pat, $str);
375 match_datestamp($pat, $str);
376 match_level($pat, $str);
378 =head1 DEBUG LOGGING HANDLER
380 This package provides C<$amanda_log_trace_log>, which sends C<die>
381 messages (and any C<g_error> or C<g_critical> calls from C) to the
382 trace log. Use it like this:
384 use Amanda::Logfile qw( $amanda_log_trace_log );
386 Amanda::Debug::add_amanda_log_handler($amanda_log_trace_log);
392 push @EXPORT_OK, qw(open_logfile get_logline close_logfile
393 log_add log_add_full);
395 push @EXPORT_OK, qw(logtype_t_to_string);
396 push @{$EXPORT_TAGS{"logtype_t"}}, qw(logtype_t_to_string);
398 my %_logtype_t_VALUES;
399 #Convert an enum value to a single string
400 sub logtype_t_to_string {
403 for my $k (keys %_logtype_t_VALUES) {
404 my $v = $_logtype_t_VALUES{$k};
406 #is this a matching flag?
407 if ($enumval == $v) {
412 #default, just return the number
416 push @EXPORT_OK, qw($L_BOGUS);
417 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_BOGUS);
419 $_logtype_t_VALUES{"L_BOGUS"} = $L_BOGUS;
421 push @EXPORT_OK, qw($L_FATAL);
422 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_FATAL);
424 $_logtype_t_VALUES{"L_FATAL"} = $L_FATAL;
426 push @EXPORT_OK, qw($L_ERROR);
427 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_ERROR);
429 $_logtype_t_VALUES{"L_ERROR"} = $L_ERROR;
431 push @EXPORT_OK, qw($L_WARNING);
432 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_WARNING);
434 $_logtype_t_VALUES{"L_WARNING"} = $L_WARNING;
436 push @EXPORT_OK, qw($L_INFO);
437 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_INFO);
439 $_logtype_t_VALUES{"L_INFO"} = $L_INFO;
441 push @EXPORT_OK, qw($L_SUMMARY);
442 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_SUMMARY);
444 $_logtype_t_VALUES{"L_SUMMARY"} = $L_SUMMARY;
446 push @EXPORT_OK, qw($L_START);
447 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_START);
449 $_logtype_t_VALUES{"L_START"} = $L_START;
451 push @EXPORT_OK, qw($L_FINISH);
452 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_FINISH);
454 $_logtype_t_VALUES{"L_FINISH"} = $L_FINISH;
456 push @EXPORT_OK, qw($L_DISK);
457 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_DISK);
459 $_logtype_t_VALUES{"L_DISK"} = $L_DISK;
461 push @EXPORT_OK, qw($L_DONE);
462 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_DONE);
464 $_logtype_t_VALUES{"L_DONE"} = $L_DONE;
466 push @EXPORT_OK, qw($L_PART);
467 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_PART);
469 $_logtype_t_VALUES{"L_PART"} = $L_PART;
471 push @EXPORT_OK, qw($L_PARTPARTIAL);
472 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_PARTPARTIAL);
474 $_logtype_t_VALUES{"L_PARTPARTIAL"} = $L_PARTPARTIAL;
476 push @EXPORT_OK, qw($L_SUCCESS);
477 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_SUCCESS);
479 $_logtype_t_VALUES{"L_SUCCESS"} = $L_SUCCESS;
481 push @EXPORT_OK, qw($L_PARTIAL);
482 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_PARTIAL);
484 $_logtype_t_VALUES{"L_PARTIAL"} = $L_PARTIAL;
486 push @EXPORT_OK, qw($L_FAIL);
487 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_FAIL);
489 $_logtype_t_VALUES{"L_FAIL"} = $L_FAIL;
491 push @EXPORT_OK, qw($L_STRANGE);
492 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_STRANGE);
494 $_logtype_t_VALUES{"L_STRANGE"} = $L_STRANGE;
496 push @EXPORT_OK, qw($L_CHUNK);
497 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_CHUNK);
499 $_logtype_t_VALUES{"L_CHUNK"} = $L_CHUNK;
501 push @EXPORT_OK, qw($L_CHUNKSUCCESS);
502 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_CHUNKSUCCESS);
504 $_logtype_t_VALUES{"L_CHUNKSUCCESS"} = $L_CHUNKSUCCESS;
506 push @EXPORT_OK, qw($L_STATS);
507 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_STATS);
509 $_logtype_t_VALUES{"L_STATS"} = $L_STATS;
511 push @EXPORT_OK, qw($L_MARKER);
512 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_MARKER);
514 $_logtype_t_VALUES{"L_MARKER"} = $L_MARKER;
516 push @EXPORT_OK, qw($L_CONT);
517 push @{$EXPORT_TAGS{"logtype_t"}}, qw($L_CONT);
519 $_logtype_t_VALUES{"L_CONT"} = $L_CONT;
521 #copy symbols in logtype_t to constants
522 push @{$EXPORT_TAGS{"constants"}}, @{$EXPORT_TAGS{"logtype_t"}};
524 push @EXPORT_OK, qw(program_t_to_string);
525 push @{$EXPORT_TAGS{"program_t"}}, qw(program_t_to_string);
527 my %_program_t_VALUES;
528 #Convert an enum value to a single string
529 sub program_t_to_string {
532 for my $k (keys %_program_t_VALUES) {
533 my $v = $_program_t_VALUES{$k};
535 #is this a matching flag?
536 if ($enumval == $v) {
541 #default, just return the number
545 push @EXPORT_OK, qw($P_UNKNOWN);
546 push @{$EXPORT_TAGS{"program_t"}}, qw($P_UNKNOWN);
548 $_program_t_VALUES{"P_UNKNOWN"} = $P_UNKNOWN;
550 push @EXPORT_OK, qw($P_PLANNER);
551 push @{$EXPORT_TAGS{"program_t"}}, qw($P_PLANNER);
553 $_program_t_VALUES{"P_PLANNER"} = $P_PLANNER;
555 push @EXPORT_OK, qw($P_DRIVER);
556 push @{$EXPORT_TAGS{"program_t"}}, qw($P_DRIVER);
558 $_program_t_VALUES{"P_DRIVER"} = $P_DRIVER;
560 push @EXPORT_OK, qw($P_REPORTER);
561 push @{$EXPORT_TAGS{"program_t"}}, qw($P_REPORTER);
563 $_program_t_VALUES{"P_REPORTER"} = $P_REPORTER;
565 push @EXPORT_OK, qw($P_DUMPER);
566 push @{$EXPORT_TAGS{"program_t"}}, qw($P_DUMPER);
568 $_program_t_VALUES{"P_DUMPER"} = $P_DUMPER;
570 push @EXPORT_OK, qw($P_CHUNKER);
571 push @{$EXPORT_TAGS{"program_t"}}, qw($P_CHUNKER);
573 $_program_t_VALUES{"P_CHUNKER"} = $P_CHUNKER;
575 push @EXPORT_OK, qw($P_TAPER);
576 push @{$EXPORT_TAGS{"program_t"}}, qw($P_TAPER);
578 $_program_t_VALUES{"P_TAPER"} = $P_TAPER;
580 push @EXPORT_OK, qw($P_AMFLUSH);
581 push @{$EXPORT_TAGS{"program_t"}}, qw($P_AMFLUSH);
583 $_program_t_VALUES{"P_AMFLUSH"} = $P_AMFLUSH;
585 push @EXPORT_OK, qw($P_AMDUMP);
586 push @{$EXPORT_TAGS{"program_t"}}, qw($P_AMDUMP);
588 $_program_t_VALUES{"P_AMDUMP"} = $P_AMDUMP;
590 push @EXPORT_OK, qw($P_AMIDXTAPED);
591 push @{$EXPORT_TAGS{"program_t"}}, qw($P_AMIDXTAPED);
593 $_program_t_VALUES{"P_AMIDXTAPED"} = $P_AMIDXTAPED;
595 push @EXPORT_OK, qw($P_AMFETCHDUMP);
596 push @{$EXPORT_TAGS{"program_t"}}, qw($P_AMFETCHDUMP);
598 $_program_t_VALUES{"P_AMFETCHDUMP"} = $P_AMFETCHDUMP;
600 push @EXPORT_OK, qw($P_AMCHECKDUMP);
601 push @{$EXPORT_TAGS{"program_t"}}, qw($P_AMCHECKDUMP);
603 $_program_t_VALUES{"P_AMCHECKDUMP"} = $P_AMCHECKDUMP;
605 push @EXPORT_OK, qw($P_AMVAULT);
606 push @{$EXPORT_TAGS{"program_t"}}, qw($P_AMVAULT);
608 $_program_t_VALUES{"P_AMVAULT"} = $P_AMVAULT;
610 #copy symbols in program_t to constants
611 push @{$EXPORT_TAGS{"constants"}}, @{$EXPORT_TAGS{"program_t"}};
613 push @EXPORT_OK, qw(find_log search_logfile dumps_match log_rename
614 match_host match_disk match_datestamp match_level);
616 push @EXPORT_OK, qw($amanda_log_trace_log);
618 push @EXPORT_OK, qw(find_all_logs find_latest_log
619 get_current_log_timestamp
625 my $logdir = shift @_ || config_dir_relative(getconf($CNF_LOGDIR));
627 opendir my $logdh, $logdir or die("can't read $logdir");
628 my @logfiles = sort grep { m{^log\.\d+\.\d+$} } readdir $logdh;
635 my $logdir = shift @_;
636 my @logs = find_all_logs($logdir || ());
643 sub get_current_log_timestamp
645 my $logfile = Amanda::Config::config_dir_relative(
646 Amanda::Config::getconf($Amanda::Config::CNF_LOGDIR)) . "/log";
648 Amanda::Debug::warning("no current logfile '$logfile'");
652 my $logh = open_logfile("$logfile");
654 Amanda::Debug::warning("could not open logfile '$logfile'");
657 while (my ($type, $prog, $str) = get_logline($logh)) {
658 if ($type == $L_START) {
659 my ($ts) = ($str =~ /date (\d+)/);
664 # no timestamp, apparently
665 Amanda::Debug::warning("no current timestamp found in logfile");
670 my ($size, $duration, $orig_kb) = @_;
672 $duration = 0.1 if $duration <= 0; # prevent division by zero
674 my $kps = "$kb.0"/$duration; # Perlish cast from BigInt to float
676 if (defined $orig_kb) {
677 return sprintf("[sec %f bytes %s kps %f orig-kb %s]", $duration, $size, $kps, $orig_kb);
679 return sprintf("[sec %f bytes %s kps %f]", $duration, $size, $kps);