distribution Log-Report-0.04.tar.gz
Mark Overmeer authored 16 years ago
Mark Overmeer committed 6 years ago
0 | 0 | |
1 | 1 | ==== version history of Log::Report |
2 | ||
3 | version 0.04: Mon Jun 4 11:05:10 CEST 2007 | |
4 | - removed incorrect doc about "mode TRY", which does not exist. | |
5 | - included syslog in "reason" comparison table | |
6 | - have Makefile.PL install xgettext-perl | |
7 | - t/50file.t needed more work-arounds to pass automated module | |
8 | tests (which go without -t STDERR) | |
9 | - attempts to make test-scripts run on various platforms. | |
2 | 10 | |
3 | 11 | version 0.03: Mon May 28 20:16:26 CEST 2007 |
4 | 12 | - Log::Report::Message without msgid forgot _append. |
1 | 1 | MANIFEST |
2 | 2 | Makefile.PL |
3 | 3 | README |
4 | bin/xgettext-perl | |
4 | 5 | lib/Log/Report.pm |
5 | 6 | lib/Log/Report/Dispatcher.pm |
6 | 7 | lib/Log/Report/Dispatcher/File.pm |
3 | 3 | |
4 | 4 | WriteMakefile |
5 | 5 | ( NAME => 'Log::Report' |
6 | , VERSION => '0.03' | |
6 | , VERSION => '0.04' | |
7 | 7 | , PREREQ_PM => { Test::More => 0.47 } |
8 | ||
9 | , EXE_FILES => [ 'bin/xgettext-perl' ] | |
10 | ||
8 | 11 | , AUTHOR => 'Mark Overmeer' |
9 | 12 | , ABSTRACT => 'report a problem, pluggable handlers and language support' |
10 | 13 | ); |
0 | #!/usr/bin/perl | |
1 | # implements xgettext for Log::Report only, using Log::Report::Extract::PPI | |
2 | # Options like GNU's xgettext | |
3 | ||
4 | use warnings; | |
5 | use strict; | |
6 | ||
7 | use Log::Report 'log-report', syntax => 'SHORT'; | |
8 | use Getopt::Long qw/:config no_ignore_case bundling/; | |
9 | ||
10 | use Log::Report::Extract::PerlPPI; | |
11 | ||
12 | my $from = 'MANIFEST'; | |
13 | my $output; | |
14 | my $lang = 'perl'; | |
15 | my $char_in = 'iso-8859-1'; | |
16 | my $char_out = 'utf-8'; | |
17 | my $merge = 0; | |
18 | my $version = 0; | |
19 | my $help = 0; | |
20 | my $mode; | |
21 | ||
22 | GetOptions | |
23 | 'files-from|f=s' => \$from | |
24 | , 'output-dir|p=s' => \$output | |
25 | , 'language|L=s' => \$lang | |
26 | , 'from-code=s' => \$char_in | |
27 | , 'to-code=s' => \$char_out # missing in xgettext? | |
28 | , 'join-existing|j=s' => \$merge | |
29 | , 'version|V' => \$version | |
30 | , 'help|h' => \$help | |
31 | , 'verbose=i' => \$mode | |
32 | , 'v+' => \$mode | |
33 | , 'mode=s' => \$mode | |
34 | or exit(1); | |
35 | ||
36 | if($version) | |
37 | { print "Log::Report $Log::Report::VERSION\n"; | |
38 | exit 0; | |
39 | } | |
40 | ||
41 | if($help) | |
42 | { print <<__HELP; | |
43 | Log::Report's version of xgettext, has a subset of options | |
44 | of GNU's version, and no own manual-page yet. | |
45 | __HELP | |
46 | } | |
47 | ||
48 | dispatcher FILE => stderr => to => \*STDERR, mode => $mode; | |
49 | ||
50 | $lang eq 'perl' | |
51 | or mistake __x"programming language {lang} not supported", lang => $lang; | |
52 | ||
53 | defined $output | |
54 | or mistake __"explicit output directory (-p) required"; | |
55 | ||
56 | -d $output or mkdir $output | |
57 | or fault __x"cannot create output directory {dir}", dir => $output; | |
58 | ||
59 | # | |
60 | ### process the pm files | |
61 | # | |
62 | ||
63 | my $ppi = Log::Report::Extract::PerlPPI->new | |
64 | ( lexicon => $output | |
65 | , charset => $char_out | |
66 | ); | |
67 | ||
68 | open FILENAMES, '<', $from | |
69 | or fault "cannot read filename list from {filename}", filename => $from; | |
70 | ||
71 | while( my $filename = <FILENAMES> ) | |
72 | { chomp $filename; | |
73 | next unless $filename =~ m/\.pm$/; | |
74 | ||
75 | $ppi->process($filename, charset => $char_in); | |
76 | } | |
77 | ||
78 | $ppi->showStats; | |
79 | ||
80 | $ppi->write; |
31 | 31 | =chapter SYNOPSIS |
32 | 32 | use Log::Dispatch::File; |
33 | 33 | dispatcher Log::Dispatch::File => 'logger', accept => 'NOTICE-' |
34 | , to_level => [ 'ALERT-' => 'err' ]; | |
34 | , filename => 'logfile', to_level => [ 'ALERT-' => 'err' ]; | |
35 | 35 | |
36 | 36 | # disable default dispatcher |
37 | 37 | dispatcher close => 'logger'; |
483 | 483 | Exactly what will be added depends on the actual mode of the dispatcher |
484 | 484 | (change it with M<mode()>, initiate it with M<new(mode)>). |
485 | 485 | |
486 | mode mode mode mode block | |
487 | REASON SOURCE TE! NORM -v -vv -vvv TRY | |
488 | trace program ... S | |
489 | assert program ... SL SL | |
490 | info program T.. S S S | |
491 | notice program T.. S S S S D | |
492 | mistake user T.. S S S SL D | |
493 | warning program T.! SL SL SL SL DL | |
494 | error user TE. S S SL SC B | |
495 | fault system TE! S S SL SC B | |
496 | alert system T.! S S SC SC S | |
497 | failure system TE! S S SC SC S | |
498 | panic program .E. SC SC SC SC SC | |
486 | mode mode mode mode | |
487 | REASON SOURCE TE! NORM -v -vv -vvv | |
488 | trace program ... S | |
489 | assert program ... SL SL | |
490 | info program T.. S S S | |
491 | notice program T.. S S S S | |
492 | mistake user T.. S S S SL | |
493 | warning program T.! SL SL SL SL | |
494 | error user TE. S S SL SC | |
495 | fault system TE! S S SL SC | |
496 | alert system T.! S S SC SC | |
497 | failure system TE! S S SC SC | |
498 | panic program .E. SC SC SC SC | |
499 | 499 | |
500 | 500 | -v = verbose, -vv = debug, -vvv = trace |
501 | 501 | T - usually translated |
954 | 954 | Various frameworks used with perl programs define different labels |
955 | 955 | to indicate the reason for the message to be produced. |
956 | 956 | |
957 | Perlish Log::Dispatch Log4Perl Log::Report | |
958 | print 0,debug debug trace | |
959 | print 0,debug debug assert | |
960 | print 1,info info info | |
961 | warn\n 2,notice info notice | |
962 | warn 3,warning warn mistake | |
963 | carp 3,warning warn warning | |
964 | die\n 4,error,err error error | |
965 | die 5,critical,crit fatal fault | |
966 | croak 6,alert fatal alert | |
967 | croak 7,emergency,emerg fatal failure | |
968 | confess 7,emergency,emerg fatal panic | |
957 | Perl5 Log::Dispatch Syslog Log4Perl Log::Report | |
958 | print 0,debug debug debug trace | |
959 | print 0,debug debug debug assert | |
960 | print 1,info info info info | |
961 | warn\n 2,notice notice info notice | |
962 | warn 3,warning warn warn mistake | |
963 | carp 3,warning warn warn warning | |
964 | die\n 4,error err error error | |
965 | die 5,critical crit fatal fault | |
966 | croak 6,alert alert fatal alert | |
967 | croak 7,emergency emerg fatal failure | |
968 | confess 7,emergency emerg fatal panic | |
969 | 969 | |
970 | 970 | =subsection Run modes |
971 | 971 | The run-mode change which messages are passed to a dispatcher, but |
6 | 6 | use_ok('POSIX', ':locale_h', 'setlocale'); |
7 | 7 | } |
8 | 8 | |
9 | my $default = setlocale(LC_MESSAGES, 'en_US'); | |
10 | ok(defined $default, 'has default locale'); | |
9 | my $default = setlocale(LC_MESSAGES) || 'none'; | |
10 | ok(1, "default locale: $default"); | |
11 | 11 | |
12 | 12 | $! = 2; |
13 | 13 | my $err_en = "$!"; |
11 | 11 | my $disp_stderr = -t STDERR ? 1 : 0; |
12 | 12 | |
13 | 13 | my @disp = dispatcher 'list'; |
14 | cmp_ok(scalar(@disp), '==', $disp_stderr); | |
15 | 14 | |
16 | isa_ok($disp[0], 'Log::Report::Dispatcher'); | |
15 | if($disp_stderr) | |
16 | { cmp_ok(scalar(@disp), '==', $disp_stderr); | |
17 | isa_ok($disp[0], 'Log::Report::Dispatcher'); | |
18 | } | |
19 | else | |
20 | { ok(1); ok(1); | |
21 | } | |
17 | 22 | |
18 | 23 | # start new dispatcher to file |
19 | 24 |