Codebase list liblog-report-perl / v0.26
distribution Log-Report-0.26.tar.gz Mark Overmeer authored 14 years ago Mark Overmeer committed 6 years ago
5 changed file(s) with 38 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
00
11 ==== version history of Log::Report
2
3 version 0.26: Mon Feb 15 10:08:23 CET 2010
4
5 Changes:
6
7 - default of 'syntax' changed from 'REPORT' to 'SHORT'.
8
9 Improvements:
10
11 - fixes in dispatcher doc "mode" table.
12
13 - document use of ::Exception::throw a bit better.
14
15 - more useful error when parameter list has odd length.
216
317 version 0.25: Thu Jul 16 12:18:51 CEST 2009
418
11
22 use 5.008;
33
4 my $version = '0.25';
4 my $version = '0.26';
55
66 my %prereq =
7 ( Test::More => 0.86
8 , Test::Pod => '1.00'
9 , Sys::Syslog => '0.27'
10 , Encode => '2.00'
7 ( Test::More => 0.86
8 , Test::Pod => '1.00'
9 , Sys::Syslog => '0.27'
10 , Encode => '2.00'
11 , Scalar::Util => 0
1112 );
1213
1314 $prereq{ 'Win32::TieRegistry' } = 0.24
534534 (change it with M<mode()>, initiate it with M<new(mode)>).
535535
536536 mode mode mode mode
537 REASON SOURCE TE! NORM -v -vv -vvv
537 REASON SOURCE TE! NORM VERB ASSE DEBUG
538538 trace program ... S
539539 assert program ... SL SL
540540 info program T.. S S S
547547 failure system TE! S S SC SC
548548 panic program .E. SC SC SC SC
549549
550 -v = verbose, -vv = debug, -vvv = trace
551550 T - usually translated
552 E - exception
551 E - exception (execution interrupted)
553552 ! - will include $! text
554 B - leave block with exception
555 D - delayed; only shown when block completes without error
556553 L - include filename and linenumber
557554 S - show/print when accepted
558555 C - stack trace (like Carp::confess())
8686 =example overrule defaults to report
8787 try { print {to => 'stderr'}, ERROR => 'oops!' };
8888 $@->reportFatal(to => 'syslog');
89
90 $exception->throw(to => 'syslog');
91
92 $@->wasFatal->throw(reason => 'WARNING', is_fatal => 0);
8993 =cut
9094
9195 # if we would used "report" here, we get a naming conflict with
7373 report ERROR => __x('gettext string', param => $param, ...)
7474 if $condition;
7575
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
7877 error __x('gettext string', param => $param, ...)
7978 if $condition;
8079
8180 # Overrule standard behavior for single message with HASH as
8281 # first parameter. Only long syntax
8382 use Errno qw/ENOMEM/;
83 use Log::Report syntax => 'REPORT';
8484 report {to => 'syslog', errno => ENOMEM}
8585 , FAULT => __x"cannot allocate {size} bytes", size => $size;
8686
256256 }
257257 else
258258 { # 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'";
260260 $message = Log::Report::Message->new(_prepend => $message, @_);
261261 }
262262
766766 the DOMAIN. For one package, it will contain configuration information.
767767 These OPTIONS are used for all packages which use the same DOMAIN.
768768
769 =option syntax 'REPORT'|'SHORT'
770 =default syntax 'REPORT'
769 =option syntax 'REPORT'|'SHORT'|'LONG'
770 =default syntax 'SHORT'
771771 The SHORT syntax will add the report abbreviations (like function
772772 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.
774775
775776 =option translator Log::Report::Translator
776777 =default translator <rescue>
793794 =examples of import
794795 use Log::Report mode => 3; # or 'DEBUG'
795796
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
798798
799799 use Log::Report 'my-domain' # in one package, top of distr
800800 , translator => Log::Report::Translator::POT->new
801801 ( lexicon => '/home/me/locale' # bindtextdomain
802802 , charset => 'UTF-8' # codeset
803803 )
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()
805806
806807 =cut
807808
810811
811812 my $textdomain = @_%2 ? shift : undef;
812813 my %opts = @_;
813 my $syntax = delete $opts{syntax} || 'REPORT';
814 my $syntax = delete $opts{syntax} || 'SHORT';
814815 my ($pkg, $fn, $linenr) = caller;
815816
816817 if(my $trans = delete $opts{translator})
838839 my @export = (@functions, @make_msg);
839840
840841 if($syntax eq 'SHORT') { push @export, @reason_functions }
841 elsif($syntax ne 'REPORT')
842 elsif($syntax ne 'REPORT' && $syntax ne 'LONG')
842843 { error __x"syntax flag must be either SHORT or REPORT, not `{syntax}'"
843844 , syntax => $syntax;
844845 }