Lintian::Output(3) Lintian messaging handling


# non-OO
use Lintian::Output qw(:messages);
msg("Something interesting");
v_msg("Something less interesting");
debug_msg(3, "Something very specific");
# OO
use Lintian::Output;
my $out = Lintian::Output->new;
$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 therefor automatically use the object $Lintian::Output::GLOBAL unless their first argument "isa('Lintian::Output')".


The following fields define the behaviours of Lintian::Output.
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).
If set to a positive integer, will enable all debug messages issued with a level lower or equal to its value.
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).

I/O handle to use for output of messages and tags. Defaults to "\*STDOUT".
I/O handle to use for warnings. Defaults to "\*STDERR".
Whether to show the description of a tag when printing it.
Hash containing the names of tags which have been issued.
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.
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.
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.

Will output the strings given in @args on stderr, one per line, each line prefixed with 'warning: '.
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.

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');
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().
Called before lintian starts to handle each package. The version in Lintian::Output uses v_msg() for output. Called from Tags::select_pkg().
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().


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.
Called by msg(), v_msg(), and debug_msg() to print the message.
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.

Called by delimiter().
Called by print_tag() to determine whether to produce colored output.
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.


If $args[0] is a 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:
Exports all the methods in ``CLASS/INSTANCE METHODS''
Exports all the methods in ``CLASS METHODS''


Originally written by Frank Lichtenheld <[email protected]> for Lintian.