73 | 73 |
report ERROR => __x('gettext string', param => $param, ...)
|
74 | 74 |
if $condition;
|
75 | 75 |
|
76 | |
# Syntax SHORT, adding error() and many other
|
77 | |
use Log::Report 'my-domain', syntax => 'SHORT';
|
|
76 |
# when syntax=SHORT (default since 0.26), many useful functions
|
78 | 77 |
error __x('gettext string', param => $param, ...)
|
79 | 78 |
if $condition;
|
80 | 79 |
|
81 | 80 |
# Overrule standard behavior for single message with HASH as
|
82 | 81 |
# first parameter. Only long syntax
|
83 | 82 |
use Errno qw/ENOMEM/;
|
|
83 |
use Log::Report syntax => 'REPORT';
|
84 | 84 |
report {to => 'syslog', errno => ENOMEM}
|
85 | 85 |
, FAULT => __x"cannot allocate {size} bytes", size => $size;
|
86 | 86 |
|
|
256 | 256 |
}
|
257 | 257 |
else
|
258 | 258 |
{ # untranslated message into object
|
259 | |
@_%2 and panic "odd length parameter list with non-translated";
|
|
259 |
@_%2 and panic "odd length parameter list with '$message'";
|
260 | 260 |
$message = Log::Report::Message->new(_prepend => $message, @_);
|
261 | 261 |
}
|
262 | 262 |
|
|
766 | 766 |
the DOMAIN. For one package, it will contain configuration information.
|
767 | 767 |
These OPTIONS are used for all packages which use the same DOMAIN.
|
768 | 768 |
|
769 | |
=option syntax 'REPORT'|'SHORT'
|
770 | |
=default syntax 'REPORT'
|
|
769 |
=option syntax 'REPORT'|'SHORT'|'LONG'
|
|
770 |
=default syntax 'SHORT'
|
771 | 771 |
The SHORT syntax will add the report abbreviations (like function
|
772 | 772 |
M<error()>) to your name-space. Otherwise, each message must be produced
|
773 | |
with M<report()>.
|
|
773 |
with M<report()>. C<LONG> is an alternative to C<REPORT>: both do not
|
|
774 |
polute your namespace with the useful abbrev functions.
|
774 | 775 |
|
775 | 776 |
=option translator Log::Report::Translator
|
776 | 777 |
=default translator <rescue>
|
|
793 | 794 |
=examples of import
|
794 | 795 |
use Log::Report mode => 3; # or 'DEBUG'
|
795 | 796 |
|
796 | |
use Log::Report 'my-domain' # in each package producing messages
|
797 | |
, syntax => 'SHORT';
|
|
797 |
use Log::Report 'my-domain'; # in each package producing messages
|
798 | 798 |
|
799 | 799 |
use Log::Report 'my-domain' # in one package, top of distr
|
800 | 800 |
, translator => Log::Report::Translator::POT->new
|
801 | 801 |
( lexicon => '/home/me/locale' # bindtextdomain
|
802 | 802 |
, charset => 'UTF-8' # codeset
|
803 | 803 |
)
|
804 | |
, native_language => 'nl_NL'; # untranslated msgs are Dutch
|
|
804 |
, native_language => 'nl_NL' # untranslated msgs are Dutch
|
|
805 |
, syntax => 'REPORT';# report ERROR, not error()
|
805 | 806 |
|
806 | 807 |
=cut
|
807 | 808 |
|
|
810 | 811 |
|
811 | 812 |
my $textdomain = @_%2 ? shift : undef;
|
812 | 813 |
my %opts = @_;
|
813 | |
my $syntax = delete $opts{syntax} || 'REPORT';
|
|
814 |
my $syntax = delete $opts{syntax} || 'SHORT';
|
814 | 815 |
my ($pkg, $fn, $linenr) = caller;
|
815 | 816 |
|
816 | 817 |
if(my $trans = delete $opts{translator})
|
|
838 | 839 |
my @export = (@functions, @make_msg);
|
839 | 840 |
|
840 | 841 |
if($syntax eq 'SHORT') { push @export, @reason_functions }
|
841 | |
elsif($syntax ne 'REPORT')
|
|
842 |
elsif($syntax ne 'REPORT' && $syntax ne 'LONG')
|
842 | 843 |
{ error __x"syntax flag must be either SHORT or REPORT, not `{syntax}'"
|
843 | 844 |
, syntax => $syntax;
|
844 | 845 |
}
|