Lintian::Output - Lintian messaging handling
# non-OO
use Lintian::Output qw(:messages);
$Lintian::Output::GLOBAL->verbosity_level(1);
msg("Something interesting");
v_msg("Something less interesting");
debug_msg(3, "Something very specific");
# OO
use Lintian::Output;
my $out = Lintian::Output->new;
$out->verbosity_level(-1);
$out->msg("Something interesting");
$out->v_msg("Something less interesting");
$out->debug_msg(3, "Something very specific");
Lintian::Output is used for all interaction between lintian and
the user. It is designed to be easily extensible via subclassing.
To simplify usage in the most common cases, many Lintian::Output
methods can be used as class methods and will therefore automatically use
the object $Lintian::Output::GLOBAL unless their
first argument
"isa('Lintian::Output')".
The following fields define the behaviours of Lintian::Output.
- verbosity_level
- Determine how verbose the output should be. "0" is the default
value (tags and msg only), "-1" is quiet (tags only) and
"1" is verbose (tags, msg and v_msg).
- debug
- If set to a positive integer, will enable all debug messages issued with a
level lower or equal to its value.
- color
- Can take the values "never", "always",
"auto" or "html".
Whether to colorize tags based on their severity. The default
is "never", which never uses color. "always" will
always use color, "auto" will use color only if the output is
going to a terminal.
"html" will output HTML <span> tags with a
color style attribute (instead of ANSI color escape sequences).
- stdout
- I/O handle to use for output of messages and tags. Defaults to
"\*STDOUT".
- stderr
- I/O handle to use for warnings. Defaults to
"\*STDERR".
- showdescription
- Whether to show the description of a tag when printing it.
- issuedtags
- Hash containing the names of tags which have been issued.
- tag_display_limit
- Get/Set the number of times a tag is emitted per processable.
These methods can be used both with and without an object. If no
object is given, they will fall back to the
$Lintian::Output::GLOBAL object.
- "msg(@args)"
- Will output the strings given in @args, one per
line, each line prefixed with 'N: '. Will do nothing if verbosity_level is
less than 0.
- "v_msg(@args)"
- Will output the strings given in @args, one per
line, each line prefixed with 'N: '. Will do nothing unless
verbosity_level is greater than 0.
- "debug_msg($level, @args)"
- $level should be a positive integer.
Will output the strings given in
@args, one per line, each line prefixed with 'N:
'. Will do nothing unless debug is set to a positive integer >=
$level.
- "warning(@args)"
- Will output the strings given in @args on stderr,
one per line, each line prefixed with 'warning: '.
- "perf_log(@args)"
- Like "v_msg", except output is possibly sent to a dedicated log
file.
Will output the strings given in
@args, one per line. The lines will not be
prefixed. Will do nothing unless perf_debug is set to a positive
integer.
- "delimiter()"
- Gives back a string that is usable for separating messages in the output.
Note: This does not print anything, it just gives back the string, use
with one of the methods above, e.g.
v_msg('foo', delimiter(), 'bar');
- "issued_tag($tag_name)"
- Indicate that the named tag has been issued. Returns a boolean value
indicating whether the tag had previously been issued by the object.
- "string($lead, @args)"
- TODO: Is this part of the public interface?
The following methods are designed to be called at specific points
during program execution and require very specific arguments. They can only
be called as instance methods.
- "print_tag($pkg_info, $tag_info, $extra, $override)"
- Print a tag. The first two arguments are hash reference with the
information about the package and the tag, $extra
is the extra information for the tag (if any) as an array reference, and
$override is either undef if the tag is not
overridden or the override for this tag. Called from
Lintian::Tags::tag().
- "print_start_pkg($pkg_info)"
- Called before lintian starts to handle each package. The version in
Lintian::Output uses v_msg() for output. Called from
Tags::select_pkg().
- "print_start_pkg($pkg_info)"
- Called after lintian is finished with a package. The version in
Lintian::Output does nothing. Called from
Lintian::Tags::file_start() and
Lintian::Tags::file_end().
- "print_first()"
- Called before lintian starts to handle any package.
- "print_last()"
- Called after lintian is finished with a package.
The following methods are only intended for subclassing and are
only available as instance methods. The methods mentioned in
"CLASS/INSTANCE METHODS" usually only check whether they should do
anything at all (according to the values of verbosity_level and debug) and
then call one of the following methods to do the actual printing. Almost all
of them finally call _print() to do that. This convoluted scheme is
necessary to be able to use the methods above as class methods and still
make the behaviour overridable in subclasses.
- "_message(@args)"
- Called by msg(), v_msg(), and debug_msg() to print
the message.
- "_warning(@args)"
- Called by warning() to print the warning.
- "_print($stream, $lead, @args)"
- Called by _message(), _warning(), and print_tag() to
do the actual printing.
If you override these three methods, you can change the
calling convention for this method to pretty much whatever you want.
The version in Lintian::Output prints the strings in
@args, one per line, each line preceded by
$lead to the I/O handle given in
$stream.
- "_delimiter()"
- Called by delimiter().
- "_do_color()"
- Called by print_tag() to determine whether to produce colored
output.
- "_quote_print($string)"
- Called to quote a string. By default it will replace all non-printables
with "?". Sub-classes can override it if they allow non-ascii
printables etc.
- "_global_or_object(@args)"
- If $args[0] is an object which satisfies
"isa('Lintian::Output')" returns
@args, otherwise returns
"($Lintian::Output::GLOBAL, @_)".
Lintian::Output exports nothing by default, but the following
export tags are available:
- :messages
- Exports all the methods in "CLASS/INSTANCE METHODS"
- :util
- Exports all the methods in "CLASS METHODS"
Originally written by Frank Lichtenheld <djpig@debian.org>
for Lintian.