Provided by: libdebbugs-perl_2.6.0ubuntu1_all
NAME
Debbugs::Log - an interface to debbugs .log files
DESCRIPTION
The Debbugs::Log module provides a convenient way for scripts to read and write the .log files used by debbugs to store the complete textual records of all bug transactions. Debbugs::Log does not decode utf8 into perl's internal encoding or encode into utf8 from perl's internal encoding. For html records and all recips, this should probably be done. For other records, this should not be needed. The .log File Format .log files consist of a sequence of records, of one of the following four types. ^A, ^B, etc. represent those control characters. incoming-recv ^G [mail] ^C "[mail]" must start with /^Received: \(at \S+\) by \S+;/, and is copied to the output. autocheck Auto-forwarded messages are recorded like this: ^A [mail] ^C "[mail]" must contain /^X-Debian-Bugs(-\w+)?: This is an autoforward from \S+/. The first line matching that is removed; all lines in the message body that begin with 'X' will be copied to the output, minus the 'X'. Nothing in debbugs actually generates this record type any more, but it may still be in old .logs at some sites. recips ^B [recip]^D[recip]^D[...] OR -t ^E [mail] ^C Each [recip] is output after "Message sent"; "-t" represents the same sendmail option, indicating that the recipients are taken from the headers of the message itself. html ^F [html] ^C [html] is copied unescaped to the output. The record immediately following this one is considered "boring" and only shown in certain output modes. (This is a design flaw in the log format, since it makes it difficult to change the HTML presentation later, or to present the data in an entirely different format.) No other types of records are permitted, and the file must end with a ^C line. Perl Record Representation Each record is a hash. The "type" field is "incoming-recv", "autocheck", "recips", or "html" as above; "text" contains text from "[mail]" or "[html]" as above; "recips" is a reference to an array of recipients (strings), or undef for "-t".
FUNCTIONS
new Creates a new log reader based on a .log filehandle. my $log = Debbugs::Log->new($logfh); my $log = Debbugs::Log->new(bug_num => $nnn); my $log = Debbugs::Log->new(logfh => $logfh); Parameters bug_num -- bug number logfh -- log filehandle log_name -- name of log One of the above options must be passed. read_record Reads and returns a single record from a log reader object. At end of file, returns undef. Throws exceptions using die(), so you may want to wrap this in an eval(). read_log_records Takes a .log filehandle as input, and returns an array of all records in that file. Throws exceptions using die(), so you may want to wrap this in an eval(). Uses exactly the same options as Debbugs::Log::new write_log_records Takes a filehandle and a list of records as input, and prints the .log format representation of those records to that filehandle. escape_log print {$log} escape_log(@log) Applies the log escape regex to the passed logfile.
CAVEATS
This module does none of the formatting that bugreport.cgi et al do. It's simply a means for extracting and rewriting raw records.