Name
Class::Usul::TraitFor::OutputLogging - Localised logging and command line output methods
Synopsis
use Moo;
extends 'Class::Usul';
with 'Class::Usul::TraitFor::OutputLogging';
Description
Localised logging and command line output methods
Configuration and Environment
Requires the following;
config
log
Defines the following command line options;
L locale
-
Print text and error messages in the selected language. If no language catalogue is supplied prints text and errors in terse English. Defaults to
en
q quiet_flag
-
Quietens the usual started/finished information messages
Subroutines/Methods
add_leader
$leader = $self->add_leader( $text, $opts );
Prepend $self->config->name
to each line of $text
. If $opts->{no_lead}
exists then do nothing. Return $text
with leader prepended
error
$self->error( $text, $opts );
Calls Class::Usul::localize with the passed options. Logs the result at the error level, then adds the program leader and prints the result to STDERR
fatal
$self->fatal( $text, $opts );
Calls Class::Usul::localize with the passed options. Logs the result at the alert level, then adds the program leader and prints the result to STDERR. Exits with a return code of one
info
$self->info( $text, $opts );
Calls Class::Usul::localize with the passed options. Logs the result at the info level, then adds the program leader and prints the result to STDOUT
loc
$localized_text = $self->loc( $message, @options );
Localises the message. Calls localizer. The domains to search are in the l10n_domains
configuration attribute. Adds $self->locale
to the arguments passed to localizer
output
$self->output( $text, $opts );
Calls Class::Usul::localize with the passed options. Adds the program leader and prints the result to STDOUT
quiet
$bool = $self->quiet( $bool );
Custom accessor/mutator for the quiet_flag
attribute. Will throw if you try to turn quiet mode off
warning
$self->warning( $text, $opts );
Calls Class::Usul::localize with the passed options. Logs the result at the warning level, then adds the program leader and prints the result to STDOUT
Diagnostics
None
Dependencies
Incompatibilities
There are no known incompatibilities in this module
Bugs and Limitations
There are no known bugs in this module. Please report problems to http://rt.cpan.org/NoAuth/Bugs.html?Dist=Class-Usul. Patches are welcome
Acknowledgements
Larry Wall - For the Perl programming language
Author
Peter Flanigan, <pjfl@cpan.org>
License and Copyright
Copyright (c) 2017 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE