+# This module is part of debbugs, and is released
+# under the terms of the GPL version 2, or any later
+# version at your option.
+# See the file README and COPYING for more information.
+#
+# [Other people have contributed to this file; their copyrights should
+# go here too.]
+# Copyright 2004 by Collin Watson <cjwatson@debian.org>
+# Copyright 2007 by Don Armstrong <don@donarmstrong.com>
+
+
package Debbugs::Log;
+
+use warnings;
use strict;
-use Exporter ();
-use vars qw($VERSION @ISA @EXPORT);
+use vars qw($VERSION $DEBUG @EXPORT @EXPORT_OK %EXPORT_TAGS);
+use base qw(Exporter);
BEGIN {
$VERSION = 1.00;
-
- @ISA = qw(Exporter);
- @EXPORT = qw(read_log_records write_log_records);
+ $DEBUG = 0 unless defined $DEBUG;
+
+ @EXPORT = ();
+ %EXPORT_TAGS = (write => [qw(write_log_records),
+ ],
+ read => [qw(read_log_records),
+ ],
+ misc => [qw(escape_log),
+ ],
+ );
+ @EXPORT_OK = ();
+ Exporter::export_ok_tags(qw(write read misc));
+ $EXPORT_TAGS{all} = [@EXPORT_OK];
}
=head1 NAME
for my $record (@records) {
my $type = $record->{type};
- my $text = $record->{text};
+ my ($text) = escapelog($record->{text});
die "type '$type' with no text field" unless defined $text;
if ($type eq 'autocheck') {
print $logfh "\01\n$text\03\n";
} else {
print $logfh "-t\n";
}
- $text =~ s/^([\01-\07\030])/\030$1/gm;
+ #$text =~ s/^([\01-\07\030])/\030$1/gm;
print $logfh "\05\n$text\03\n";
} elsif ($type eq 'html') {
print $logfh "\06\n$text\03\n";
} elsif ($type eq 'incoming-recv') {
- $text =~ s/^([\01-\07\030])/\030$1/gm;
+ #$text =~ s/^([\01-\07\030])/\030$1/gm;
print $logfh "\07\n$text\03\n";
} else {
die "unknown type '$type'";
1;
}
+=head2 escapelog
+
+ print {$log} escapelog(@log)
+
+Applies the log escape regex to the passed logfile.
+
+=cut
+
+sub escape_log {
+ my @log = @_;
+ return map { s/^([\01-\07\030])/\030$1/gm; $_ } @log;
+}
+
+
=back
=head1 CAVEATS