Codebase list liblog-report-perl / v0.95
distribution Log-Report-0.95.tar.gz Mark Overmeer authored 11 years ago Mark Overmeer committed 6 years ago
37 changed file(s) with 1040 addition(s) and 493 deletion(s). Raw diff Collapse all Expand all
00
11 ==== version history of Log::Report
2
3 version 0.95:
4
5 Changes:
6
7 - new parameters for xgettext-perl, now also able to handle
8 extracting from templates. Script needs man-page.
9
10 Fixes:
11
12 - xgettext-perl showed counts twice.
13
14 - text-domain specified as "qw/domain/" now gets recognized by PerlPPI.
15
16 Improvements:
17
18 - some spelling corrections by rt.cpan.org#70959 [Fabrizio Regalli]
19
20 - synopsis fix in ::Dispatcher::Callback by [gbjk]
21
22 - cleaned-up the synopsis of Log::Report a bit.
23
24 - split base-class Log::Report::Extract from ::Extract::PerlPPI
25
26 - remove dependency to Test::Pod
27
28 - add Log::Report::Extract::Template and t/42templ.t
229
330 version 0.94: Tue Aug 23 11:14:59 CEST 2011
431
1313 lib/Log/Report/Dispatcher/Syslog.pm
1414 lib/Log/Report/Dispatcher/Try.pm
1515 lib/Log/Report/Exception.pm
16 lib/Log/Report/Extract.pm
1617 lib/Log/Report/Extract/PerlPPI.pm
18 lib/Log/Report/Extract/Template.pm
1719 lib/Log/Report/Lexicon/Index.pm
1820 lib/Log/Report/Lexicon/PO.pm
1921 lib/Log/Report/Lexicon/POT.pm
3840 t/31stack.t
3941 t/40ppi.t
4042 t/41die.t
43 t/42templ.t
4144 t/50file.t
4245 t/51syslog.t
4346 t/52logdisp.t
4447 t/53log4perl.t
4548 t/54try.t
46 t/99pod.t
4749 t/DieTests.pm
4850 t/hello-world-slovak.po
51 xt/99pod.t
11
22 use 5.008;
33
4 my $version = '0.94';
4 my $version = '0.95';
55
66 my %prereq =
77 ( Test::More => 0.86
8 , Test::Pod => '1.00'
98 , Sys::Syslog => '0.27'
109 , Encode => '2.00'
1110 , Scalar::Util => 0
4645
4746 # for Log::Report
4847 xgettext: $(TO_INST_PM)
49 PERL5LIB=lib bin/xgettext-perl --mode=VERBOSE \
50 -p lib/Log/Report/messages
48 PERL5LIB=lib bin/xgettext-perl --mode=DEBUG \
49 -p lib/Log/Report/messages lib bin
5150 __POSTAMBLE
66
77 use Log::Report 'log-report', syntax => 'SHORT';
88 use Getopt::Long qw/:config no_ignore_case bundling/;
9 use File::Find qw/find/;
910
10 use Log::Report::Extract::PerlPPI;
11
12 my $from = 'MANIFEST';
13 my $output;
1411 my $lang = 'perl';
15 my $char_in = 'iso-8859-1';
16 my $char_out = 'utf-8';
17 my $merge = 0;
1812 my $version = 0;
1913 my $help = 0;
20 my $mode;
14 my ($from, $output);
15 my ($char_in, $char_out, $domain, $mode, $template);
2116
2217 GetOptions
2318 'files-from|f=s' => \$from
2419 , 'output-dir|p=s' => \$output
20 , 'domain|d=s' => \$domain
2521 , 'language|L=s' => \$lang
2622 , 'from-code=s' => \$char_in
2723 , 'to-code=s' => \$char_out # missing in xgettext?
28 , 'join-existing|j=s' => \$merge
2924 , 'version|V' => \$version
3025 , 'help|h' => \$help
26 , 'template|t=s' => \$template # pattern in ::Template
3127 , 'verbose=i' => \$mode
3228 , 'v+' => \$mode
3329 , 'mode=s' => \$mode
4642 exit 0;
4743 }
4844
45 # all output to stderr
4946 dispatcher FILE => stderr => to => \*STDERR, mode => $mode;
47 dispatcher close => 'default';
5048
51 $lang eq 'perl'
49 $template || $lang eq 'perl'
5250 or mistake __x"programming language {lang} not supported", lang => $lang;
5351
5452 defined $output
5755 -d $output or mkdir $output
5856 or fault __x"cannot create output directory {dir}", dir => $output;
5957
60 #
61 ### process the pm files
62 #
58 my @filenames;
59 if(defined $from)
60 { !@ARGV
61 or error __x"do not combine command-line filenames with --files-from";
6362
64 my $ppi = Log::Report::Extract::PerlPPI->new
65 ( lexicon => $output
66 , charset => $char_out
67 );
63 open FILENAMES, '<:raw', $from
64 or fault __x"cannot read filename list from {fn}", fn => $from;
6865
69 open FILENAMES, '<', $from
70 or fault "cannot read filename list from {filename}", filename => $from;
71
72 while( my $filename = <FILENAMES> )
73 { chomp $filename;
74 next unless $filename =~ m/\.pm$/;
75
76 $ppi->process($filename, charset => $char_in);
66 @filenames = <FILENAMES>;
67 close FILENAMES;
68 chomp(@filenames);
69 }
70 elsif(@ARGV)
71 { find sub{push @filenames, $File::Find::name if -f}, @ARGV;
7772 }
7873
79 $ppi->showStats;
74 my $extr;
8075
81 $ppi->write;
76 if($template)
77 { # process from template
78 eval "require Log::Report::Extract::Template";
79 panic $@ if $@;
80
81 $domain
82 or error __x"specify a text-domain (-d) for the templates";
83
84 $extr = Log::Report::Extract::Template->new
85 ( lexicon => $output
86 , charset => $char_out
87 , domain => $domain
88 , pattern => 'TT2-loc'
89 );
90
91 $extr->process($_, charset => $char_in)
92 for @filenames;
93 }
94 else
95 { # process the pm files
96 eval "require Log::Report::Extract::PerlPPI";
97 panic $@ if $@;
98
99 $extr = Log::Report::Extract::PerlPPI->new
100 ( lexicon => $output
101 , charset => $char_out
102 );
103
104 $extr->process($_, charset => $char_in)
105 for @filenames;
106 }
107
108 $extr->showStats;
109 $extr->write;
1010
1111 =chapter SYNOPSIS
1212 sub cb($$$)
13 { my ($options, $reason, $message) = @_;
13 { my ($disp, $options, $reason, $message) = @_;
1414 ...
1515 }
1616
22 use strict;
33
44 package Log::Report::Extract::PerlPPI;
5
6 use Log::Report 'log-report', syntax => 'SHORT';
7
8 use Log::Report::Lexicon::Index ();
9 use Log::Report::Lexicon::POT ();
10
5 use base 'Log::Report::Extract';
6
7 use Log::Report 'log-report';
118 use PPI;
129
1310 # See Log::Report translation markup functions
3027 ( lexicon => '/usr/share/locale'
3128 );
3229 $ppi->process('lib/My/Pkg.pm'); # many times
33 $ppi->showStats; # to dispatchers which accept TRACE or INFO
34 $ppi->write; # also cleans processing memory.
30 $ppi->showStats;
31 $ppi->write;
32
33 # See script xgettext-perl
3534
3635 =chapter DESCRIPTION
3736 This module helps maintaining the POT files, updating the list of
4443
4544 =section Constructors
4645
47 =c_method new OPTIONS
48 =requires lexicon DIRECTORY
49 The place where the lexicon is kept. When no lexicon is defined yet,
50 this will be the directory where an C<domain/xx.po> file will be created.
51
52 =option charset STRING
53 =default charset 'utf-8'
54 The character-set used in the PO files.
55
56 =cut
57
58 sub new(@)
59 { my $class = shift;
60 (bless {}, $class)->init( {@_} );
61 }
62
63 sub init($)
64 { my ($self, $args) = @_;
65 my $lexi = $args->{lexicon}
66 or error __"PerlPPI requires explicit lexicon directory";
67
68 -d $lexi or mkdir $lexi
69 or fault __x"cannot create lexicon directory {dir}", dir => $lexi;
70
71 $self->{index} = Log::Report::Lexicon::Index->new($lexi);
72 $self->{charset} = $args->{charset} || 'utf-8';
73 $self;
74 }
75
7646 =section Accessors
77
78 =method index
79 Returns the M<Log::Report::Lexicon::Index> object, which is listing
80 the files in the lexicon directory tree.
81
82 =method charset
83 Returns the character-set used inside the POT files.
84
85 =method domains
86 Returns a sorted list of all known domain names.
87 =cut
88
89 sub index() {shift->{index}}
90 sub charset() {shift->{charset}}
91 sub domains() {sort keys %{shift->{domains}}}
9247
9348 =section Processors
9449
10560 { my ($self, $fn, %opts) = @_;
10661
10762 my $charset = $opts{charset} || 'iso-8859-1';
108 info __x"processing file {fn} in {charset}", fn=> $fn, charset => $charset;
10963
11064 $charset eq 'iso-8859-1'
11165 or error __x"PPI only supports iso-8859-1 (latin-1) on the moment";
11367 my $doc = PPI::Document->new($fn, readonly => 1)
11468 or fault __x"cannot read from file {filename}", filename => $fn;
11569
116 my ($pkg, $include, $domain) = ('main', 0, undef);
70 my @childs = $doc->schildren;
71 if(@childs==1 && ref $childs[0] eq 'PPI::Statement')
72 { info __x"no Perl in file {filename}", filename => $fn;
73 return 0;
74 }
75
76 info __x"processing file {fn} in {charset}", fn=> $fn, charset => $charset;
77 my ($pkg, $include, $domain, $msgs_found) = ('main', 0, undef, 0);
11778
11879 NODE:
11980 foreach my $node ($doc->schildren)
12081 { if($node->isa('PPI::Statement::Package'))
12182 { $pkg = $node->namespace;
12283
123 # special hack for module Log::Report itself
84 # special hack needed for module Log::Report itself
12485 if($pkg eq 'Log::Report')
12586 { ($include, $domain) = (1, 'log-report');
12687 $self->_reset($domain, $fn);
12788 }
12889 else { ($include, $domain) = (0, undef) }
129
13090 next NODE;
13191 }
13292
13393 if($node->isa('PPI::Statement::Include'))
134 { next NODE if $node->type ne 'use' || $node->module ne 'Log::Report';
94 { $node->type eq 'use' && $node->module eq 'Log::Report'
95 or next NODE;
96
13597 $include++;
13698 my $dom = ($node->schildren)[2];
137 $domain = $dom->isa('PPI::Token::Quote') ? $dom->string : undef;
99 $domain
100 = $dom->isa('PPI::Token::Quote') ? $dom->string
101 : $dom->isa('PPI::Token::QuoteLike::Words') ? ($dom->literal)[0]
102 : undef;
103
138104 $self->_reset($domain, $fn);
139105 }
140106
143109 $_[1]->isa('PPI::Token::Word') or return 0;
144110
145111 my $node = $_[1];
146 my $def = $msgids{$node->content}
112 my $def = $msgids{$node->content} # get __() description
147113 or return 0;
148114
149115 my @msgids = $self->_get($node, @$def)
152118 my $line = $node->location->[0];
153119 unless($domain)
154120 { mistake __x
155 "no textdomain for translatable at {fn} line {line}"
121 "no text-domain for translatable at {fn} line {line}"
156122 , fn => $fn, line => $line;
157123 return 0;
158124 }
159125
160 if($def->[4]) # split
161 { $self->_store($domain, $fn, $line, $_)
162 for map {split} @msgids;
126 if($def->[4]) # must split? Bulk conversion strings
127 { my @words = map {split} @msgids;
128 $self->store($domain, $fn, $line, $_) for @words;
129 $msgs_found += @words;
163130 }
164131 else
165 { $self->_store($domain, $fn, $line, @msgids);
132 { $self->store($domain, $fn, $line, @msgids);
133 $msgs_found += 1;
166134 }
167135
168136 0; # don't collect
169137 }
170138 );
171139 }
140
141 $msgs_found;
172142 }
173143
174 sub _get($$$$$)
144 sub _get($@)
175145 { my ($self, $node, $msgids, $count, $opts, $vars, $split) = @_;
176146 my $list_only = ($msgids > 1) || $count || $opts || $vars;
177147 my $expand = $opts || $vars;
226196 @msgids;
227197 }
228198
229 =method showStats [DOMAINs]
230 Show a status about the DOMAIN (by default all domains). At least mode
231 verbose is required to see this.
232 =cut
233
234 sub showStats(;$)
235 { dispatcher needs => 'INFO'
236 or return;
237
238 my $self = shift;
239 my @domains = @_ ? @_ : $self->domains;
240
241 foreach my $domain (@domains)
242 { my $pots = $self->{domains}{$domain} or next;
243 my ($msgids, $fuzzy, $inactive) = (0, 0, 0);
244
245 foreach my $pot (@$pots)
246 { my $stats = $pot->stats;
247 next unless $stats->{fuzzy} || $stats->{inactive};
248
249 $msgids = $stats->{msgids};
250 next if $msgids == $stats->{fuzzy}; # ignore the template
251
252 notice __x
253 "{domain}: {fuzzy%3d} fuzzy, {inact%3d} inactive in {filename}"
254 , domain => $domain, fuzzy => $stats->{fuzzy}
255 , inact => $stats->{inactive}, filename => $pot->filename;
256
257 $fuzzy += $stats->{fuzzy};
258 $inactive += $stats->{inactive};
259 }
260
261 if($fuzzy || $inactive)
262 { info __xn
263 "{domain}: one file with {ids} msgids, {f} fuzzy and {i} inactive translations"
264 , "{domain}: {_count} files each {ids} msgids, {f} fuzzy and {i} inactive translations in total"
265 , scalar(@$pots), domain => $domain
266 , f => $fuzzy, ids => $msgids, i => $inactive
267 }
268 else
269 { info __xn
270 "{domain}: one file with {ids} msgids"
271 , "{domain}: {_count} files with each {ids} msgids"
272 , scalar(@$pots), domain => $domain, ids => $msgids;
273 }
274 }
275 }
276
277 =method write [DOMAIN]
278 Update the information of the files related to DOMAIN, by default all
279 processed DOMAINS. All information known about the DOMAIN is removed
280 from the cache.
281 =cut
282
283 sub write(;$)
284 { my ($self, $domain) = @_;
285 unless(defined $domain) # write all
286 { $self->write($_) for keys %{$self->{domains}};
287 return;
288 }
289
290 my $pots = delete $self->{domains}{$domain}
291 or return; # nothing found
292
293 for my $pot (@$pots)
294 { $pot->updated;
295 $pot->write;
296 }
297
298 $self;
299 }
300
301 sub DESTROY() {shift->write}
302
303 sub _reset($$)
304 { my ($self, $domain, $fn) = @_;
305
306 my $pots = $self->{domains}{$domain}
307 ||= $self->_read_pots($domain);
308
309 $_->removeReferencesTo($fn) for @$pots;
310 }
311
312 sub _read_pots($)
313 { my ($self, $domain) = @_;
314
315 my $index = $self->index;
316 my $charset = $self->charset;
317
318 my @pots = map {Log::Report::Lexicon::POT->read($_, charset=> $charset)}
319 $index->list($domain);
320
321 trace __xn "found one pot file for domain {domain}"
322 , "found {_count} pot files for domain {domain}"
323 , @pots, domain => $domain;
324
325 @pots && return \@pots;
326
327 # new textdomain
328 my $fn = $index->addFile("$domain.$charset.po");
329 info __x"starting new textdomain {domain}, template in {filename}"
330 , domain => $domain, filename => $fn;
331
332 my $pot = Log::Report::Lexicon::POT->new
333 ( textdomain => $domain
334 , filename => $fn
335 , charset => $charset
336 , version => 0.01
337 );
338
339 [ $pot ];
340 }
341
342 sub _store($$$$;$)
343 { my ($self, $domain, $fn, $linenr, $msgid, $plural) = @_;
344
345 foreach my $pot ( @{$self->{domains}{$domain}} )
346 { if(my $po = $pot->msgid($msgid))
347 { $po->addReferences( ["$fn:$linenr"]);
348 $po->plural($plural) if $plural;
349 next;
350 }
351
352 my $format = $msgid =~ m/\{/ ? 'perl-brace' : 'perl';
353 my $po = Log::Report::Lexicon::PO->new
354 ( msgid => $msgid
355 , msgid_plural => $plural
356 , fuzzy => 1
357 , format => $format
358 , references => [ "$fn:$linenr" ]
359 );
360
361 $pot->add($po);
362 }
363 }
364
365199 1;
0
1 use warnings;
2 use strict;
3
4 package Log::Report::Extract::Template;
5 use base 'Log::Report::Extract';
6
7 use Log::Report 'log-report';
8
9 =chapter NAME
10 Log::Report::Extract::Template - Collect translatable strings from templates
11
12 =chapter SYNOPSIS
13 my $extr = Log::Report::Extract::Template->new
14 ( lexicon => '/usr/share/locale'
15 , domain => 'my-web-site'
16 , pattern => 'TT2-loc'
17 );
18 $extr->process('website/page.html'); # many times
19 $extr->showStats;
20 $extr->write;
21
22 # See script xgettext-perl
23
24 =chapter DESCRIPTION
25 This module helps maintaining the POT files which list translatable
26 strings from template files by updating the list of message-ids which
27 are kept in them.
28
29 After initiation, the M<process()> method needs to be called with
30 all files which changed since last processing and the existing PO
31 files will get updated accordingly. If no translations exist yet,
32 one C<textdomain/xx.po> file will be created.
33
34 =chapter METHODS
35
36 =section Constructors
37
38 =c_method new OPTIONS
39
40 =requires domain DOMAIN
41 There is no syntax for specifying domains in templates (yet), so you
42 must be explicit about the collection we are making now.
43
44 =option pattern PREDEFINED|REGEX
45 =default pattern <undef>
46 See the DETAILS section below for a detailed explenation.
47 =cut
48
49 sub init($)
50 { my ($self, $args) = @_;
51 $self->SUPER::init($args);
52 $self->{LRET_domain} = $args->{domain}
53 or error "template extract requires explicit domain";
54
55 $self->{LRET_pattern} = $self->_pattern($args->{pattern});
56 $self;
57 }
58
59 =section Accessors
60 =method domain
61 =method pattern
62 =cut
63
64 sub domain() {shift->{LRET_domain}}
65 sub pattern() {shift->{LRET_pattern}}
66
67 =section Processors
68
69 =method process FILENAME, OPTIONS
70 Update the domains mentioned in the FILENAME. All textdomains defined
71 in the file will get updated automatically, but not written before
72 all files where processed.
73
74 =option charset STRING
75 =default charset 'utf-8'
76 The character encoding used in this template file.
77
78 =option pattern PREDEFINED|REGEX
79 =default pattern <from new(pattern)>
80 Read the DETAILS section about this.
81 =cut
82
83 sub process($@)
84 { my ($self, $fn, %opts) = @_;
85
86 my $charset = $opts{charset} || 'utf-8';
87 info __x"processing file {fn} in {charset}", fn=> $fn, charset => $charset;
88
89 # Slurp the whole file
90 local *IN;
91 open IN, "<:encoding($charset)", $fn
92 or fault __x"cannot read template from {fn}", fn => $fn;
93
94 undef $/;
95 my $text = <IN>;
96 close IN;
97
98 my $domain = $self->domain;
99 $self->_reset($domain, $fn);
100
101 my $pattern = $self->_pattern($opts{pattern}) || $self->pattern
102 or error __"need pattern to scan for, either via new() or process()";
103
104 # Split the whole file on the pattern in four fragments per match:
105 # (text, leading, needed trailing, text, leading, ...)
106 # f.i. ('', '[% loc("', 'some-msgid', '", params) %]', ' more text')
107 my @frags = split $pattern, $text;
108
109 my $linenr = 1;
110 my $msgs_found = 0;
111
112 while(@frags > 4)
113 { $linenr += ($frags[0] =~ tr/\n//) # text
114 + ($frags[1] =~ tr/\n//); # leading
115 (my $msgid = $frags[2]) =~ s/^(['"]*)(.*?)\1/$2/;
116 $self->store($domain, $fn, $linenr, $msgid);
117 $msgs_found++;
118 $linenr += ($frags[2] =~ tr/\n//)
119 + ($frags[3] =~ tr/\n//);
120 splice @frags, 0, 4;
121 }
122
123 $msgs_found;
124 }
125
126 #----------------------------------------------------
127 =chapter DETAILS
128
129 =section Scan Patterns
130 Various template systems use different conventions for denoting strings
131 to be translated.
132
133 =subsection Your own regular expression
134 If you do not have a format which is predefined, then you can pass-in
135 your own regular expression. Be sure it captures three components:
136 the beginning of the markup, the msgid to be included in the translation
137 table, and the ending of the markup.
138
139 Example:
140
141 pattern => qr/(<")(.*?)(">)/
142
143 This would match
144
145 <"Hello, World">
146
147 The markup compenents must contain all allowed white-spacing, to be able
148 to produce the correct line-numbers. Enclosing single and double quotes
149 aroung the msgid will get removed, if still present after the match.
150
151 =subsection Predefined for Template::Toolkit
152 There is not a single convertion for translations in M<Template::Toolkit>,
153 so you need to specify which version you use and which function you want
154 to run.
155
156 For instance
157
158 pattern => 'TT2-loc'
159
160 will scan for
161
162 [% loc("msgid", params) %]
163
164 For TT1, the brackets can either be '[%...%]' or '%%...%%'. The function
165 name is treated case-sensitive. Some people prefer 'l()'.
166 =cut
167
168 sub _pattern($)
169 { my ($self, $pattern) = @_;
170
171 return $pattern
172 if !defined $pattern || ref $pattern eq 'Regexp';
173
174 if($pattern =~ m/^TT([12])-(\w+)$/)
175 { # Recognized is Template::Toolkit 2
176 my ($level, $function) = ($1, $2);
177 my ($open, $close) = $level==1 ? ('[\[%]%', '%[\]%]') : ('\[%', '%\]');
178
179 return qr/( $open \s* \Q$function\E \s* \( \s* ) # leading
180 ( "[^"\s]*" | '[^']*' ) # msgid
181 ( .*? # params
182 $close ) # ending
183 /xs;
184 }
185
186 error __x"scan pattern `{pattern}' not recognized", pattern => $pattern;
187 }
188
189 1;
0
1 use warnings;
2 use strict;
3
4 package Log::Report::Extract;
5
6 use Log::Report 'log-report';
7 use Log::Report::Lexicon::Index ();
8 use Log::Report::Lexicon::POT ();
9
10 =chapter NAME
11 Log::Report::Extract - Collect translatable strings
12
13 =chapter SYNOPSIS
14 # See the extensions
15
16 =chapter DESCRIPTION
17 This module helps maintaining the POT files, updating the list of
18 message-ids which are kept in them. After initiation, the M<process()>
19 method needs to be called with all files which changed since last
20 processing and the existing PO files will get updated accordingly. If no
21 translations exist yet, one C<textdomain/xx.po> file will be created.
22
23 =chapter METHODS
24
25 =section Constructors
26
27 =c_method new OPTIONS
28 =requires lexicon DIRECTORY
29 The place where the lexicon is kept. When no lexicon is defined yet,
30 this will be the directory where an C<domain/xx.po> file will be created.
31
32 =option charset STRING
33 =default charset 'utf-8'
34 The character-set used in the PO files.
35
36 =cut
37
38 sub new(@)
39 { my $class = shift;
40 (bless {}, $class)->init( {@_} );
41 }
42
43 sub init($)
44 { my ($self, $args) = @_;
45 my $lexi = $args->{lexicon}
46 or error __"extractions require an explicit lexicon directory";
47
48 -d $lexi or mkdir $lexi
49 or fault __x"cannot create lexicon directory {dir}", dir => $lexi;
50
51 $self->{LRE_index} = Log::Report::Lexicon::Index->new($lexi);
52 $self->{LRE_charset} = $args->{LRE_charset} || 'utf-8';
53 $self->{LRE_domains} = {};
54 $self;
55 }
56
57 =section Accessors
58
59 =method index
60 Returns the M<Log::Report::Lexicon::Index> object, which is listing
61 the files in the lexicon directory tree.
62
63 =method charset
64 Returns the character-set used inside the POT files.
65
66 =method domains
67 Returns a sorted list of all known domain names.
68
69 =method pots DOMAIN
70 Returns the list of M<Log::Report::Lexicon::POT> objects which contain
71 the tables for DOMAIN.
72 =cut
73
74 sub index() {shift->{LRE_index}}
75 sub charset() {shift->{LRE_charset}}
76 sub domains() {sort keys %{shift->{LRE_domains}}}
77 sub pots($)
78 { my ($self, $domain) = @_;
79 my $r = $self->{LRE_domains}{$domain};
80 $r ? @$r : ();
81 }
82
83 =section Processors
84
85 =method process FILENAME, OPTIONS
86 Update the domains mentioned in the FILENAME. All text-domains defined
87 in the file will get updated automatically, but should not written before
88 all files are processed.
89
90 Returned is the number of messages found in this particular file.
91 =cut
92
93 sub process($@)
94 { my ($self, $fn, %opts) = @_;
95 panic "not implemented";
96 }
97
98 =method showStats [DOMAINs]
99 Show a status about the DOMAIN (by default all domains). At least mode
100 verbose is required to see this.
101
102 The statistics are sent to (Log::Report) dispatchers which accept
103 notice and info. This could be syslog. When you have no explicit
104 dispatchers in your program, the level of detail get controled by
105 the 'mode':
106
107 use Log::Report mode => 'DEBUG'; # or 'VERBOSE'
108 =cut
109
110 sub showStats(;$)
111 { dispatcher needs => 'INFO'
112 or return;
113
114 my $self = shift;
115 my @domains = @_ ? @_ : $self->domains;
116
117 foreach my $domain (@domains)
118 { my $pots = $self->{LRE_domains}{$domain} or next;
119 my ($msgids, $fuzzy, $inactive) = (0, 0, 0);
120
121 foreach my $pot (@$pots)
122 { my $stats = $pot->stats;
123 next unless $stats->{fuzzy} || $stats->{inactive};
124
125 $msgids = $stats->{msgids};
126 next if $msgids == $stats->{fuzzy}; # ignore the template
127
128 notice __x
129 "{domain}: {fuzzy%3d} fuzzy, {inact%3d} inactive in {filename}"
130 , domain => $domain, fuzzy => $stats->{fuzzy}
131 , inact => $stats->{inactive}, filename => $pot->filename;
132
133 $fuzzy += $stats->{fuzzy};
134 $inactive += $stats->{inactive};
135 }
136
137 if($fuzzy || $inactive)
138 { info __xn
139 "{domain}: one file with {ids} msgids, {f} fuzzy and {i} inactive translations"
140 , "{domain}: {_count} files each {ids} msgids, {f} fuzzy and {i} inactive translations in total"
141 , scalar(@$pots), domain => $domain
142 , f => $fuzzy, ids => $msgids, i => $inactive
143 }
144 else
145 { info __xn
146 "{domain}: one file with {ids} msgids"
147 , "{domain}: {_count} files with each {ids} msgids"
148 , scalar(@$pots), domain => $domain, ids => $msgids;
149 }
150 }
151 }
152
153 =method write [DOMAIN]
154 Update the information of the files related to DOMAIN, by default all
155 processed DOMAINS.
156
157 All information known about the written DOMAIN is removed from the cache.
158 =cut
159
160 sub write(;$)
161 { my ($self, $domain) = @_;
162 unless(defined $domain) # write all
163 { $self->write($_) for $self->domains;
164 return;
165 }
166
167 my $pots = delete $self->{LRE_domains}{$domain}
168 or return; # nothing found
169
170 for my $pot (@$pots)
171 { $pot->updated;
172 $pot->write;
173 }
174
175 $self;
176 }
177
178 sub DESTROY() {shift->write}
179
180 sub _reset($$)
181 { my ($self, $domain, $fn) = @_;
182
183 my $pots = $self->{LRE_domains}{$domain}
184 ||= $self->_read_pots($domain);
185
186 $_->removeReferencesTo($fn) for @$pots;
187 }
188
189 sub _read_pots($)
190 { my ($self, $domain) = @_;
191
192 my $index = $self->index;
193 my $charset = $self->charset;
194
195 my @pots = map Log::Report::Lexicon::POT->read($_, charset=> $charset),
196 $index->list($domain);
197
198 trace __xn "found one pot file for domain {domain}"
199 , "found {_count} pot files for domain {domain}"
200 , @pots, domain => $domain;
201
202 return \@pots
203 if @pots;
204
205 # new text-domain found, start template
206 my $fn = $index->addFile("$domain.$charset.po");
207 info __x"starting new textdomain {domain}, template in {filename}"
208 , domain => $domain, filename => $fn;
209
210 my $pot = Log::Report::Lexicon::POT->new
211 ( textdomain => $domain
212 , filename => $fn
213 , charset => $charset
214 , version => 0.01
215 );
216
217 [ $pot ];
218 }
219
220 =method store DOMAIN, FILENAME, LINENR, MSG, [MSG_PLURAL]
221 Register the existence of a (MSG, MSG_PLURAL) in all POTs of
222 the DOMAIN.
223 =cut
224
225 sub store($$$$;$)
226 { my ($self, $domain, $fn, $linenr, $msgid, $plural) = @_;
227
228 foreach my $pot ($self->pots($domain))
229 { if(my $po = $pot->msgid($msgid))
230 { $po->addReferences( ["$fn:$linenr"]);
231 $po->plural($plural) if $plural;
232 next;
233 }
234
235 my $format = $msgid =~ m/\{/ ? 'perl-brace' : 'perl';
236 my $po = Log::Report::Lexicon::PO->new
237 ( msgid => $msgid
238 , msgid_plural => $plural
239 , fuzzy => 1
240 , format => $format
241 , references => [ "$fn:$linenr" ]
242 );
243
244 $pot->add($po);
245 }
246 }
247
248 1;
167167 The EXTENSION filter can be used to reduce the filenames further, for
168168 instance to select only C<po> or only C<mo> files, and ignore readme's.
169169 Use an string, without dot and interpreted case-insensitive, or a
170 regular expresion.
170 regular expression.
171171
172172 =example
173173 my @l = $index->list('my-domain');
180180 my $domain = lc shift;
181181 my $filter = shift;
182182 my $index = $self->index;
183
184 my @list =
185 map { $index->{$_} }
186 grep { m! \b\Q$domain\E\b !x }
187 keys %$index;
183 my @list = map $index->{$_}, grep m!\b\Q$domain\E\b!, keys %$index;
188184
189185 defined $filter
190186 or return @list;
192188 $filter = qr/\.\Q$filter\E$/i
193189 if defined $filter && ref $filter ne 'Regexp';
194190
195 grep { $_ =~ $filter } @list;
191 grep $_ =~ $filter, @list;
196192 }
197193
198194 =chapter DETAILS
4545
4646 =option automatic PARAGRAPH
4747 =default automatic ""
48 Automaticly added comments.
48 Automatically added comments.
4949 See M<addAutomatic()>.
5050
5151 =option references STRING|ARRAY-OF-LOCATIONS
9494 category of the message.
9595
9696 One message can be part of multiple classes. The STRING is used as
97 comma- and/or blank seperated list of class tokens, the ARRAY lists all
98 tokens seperately. See M<classes()>.
97 comma- and/or blank separated list of class tokens, the ARRAY lists all
98 tokens separately. See M<classes()>.
9999
100100 =option _classes STRING|ARRAY
101101 =default _classes []
2626
2727 =chapter DESCRIPTION
2828 A module (or distribution) has a certain way of translating messages,
29 usually C<gettext>. The translator is based on the C<textdomain>
29 usually C<gettext>. The translator is based on some C<textdomain>
3030 for the message, which can be specified as option per text element,
3131 but usually is package scoped.
3232
77 our @EXPORT = qw/@reasons %reason_code
88 parse_locale expand_reasons escape_chars unescape_chars/;
99
10 use Log::Report 'log-report', syntax => 'SHORT';
10 use Log::Report 'log-report';
1111
1212 # ordered!
1313 our @reasons = N__w('TRACE ASSERT INFO NOTICE WARNING
33 "Project-Id-Version: log-report 0.01\n"
44 "Report-Msgid-Bugs-To:\n"
55 "POT-Creation-Date: 2007-05-14 17:14+0200\n"
6 "PO-Revision-Date: 2009-04-27 09:47+0200\n"
6 "PO-Revision-Date: 2012-08-30 21:52+0200\n"
77 "Last-Translator: Mark Overmeer <mark@overmeer.net>\n"
88 "Language-Team:\n"
99 "MIME-Version: 1.0\n"
6565 msgid "PANIC"
6666 msgstr "PANIEK"
6767
68 #: lib/Log/Report/Extract/PerlPPI.pm:112
68 #: lib/Log/Report/Extract/PerlPPI.pm:66
6969 msgid "PPI only supports iso-8859-1 (latin-1) on the moment"
7070 msgstr "PPI ondersteunt momenteel alleen iso-8859-1 (latin-1)"
7171
7373 msgid "Perl does not support charset {cs}"
7474 msgstr "Perl heeft geen support voor tekenset {cs}"
7575
76 #: lib/Log/Report/Extract/PerlPPI.pm:67
77 msgid "PerlPPI requires explicit lexicon directory"
78 msgstr "PerlPPI verwacht een expliciet vermeldde lexicon directory"
79
8076 #: lib/Log/Report/Util.pm:14
8177 msgid "TRACE"
8278 msgstr "TRACE"
8379
84 #: lib/Log/Report.pm:225
85 msgid "Token '{token}' not recognized as reason"
86 msgstr "'{token}' is niet herkend als rapportage reden"
87
8880 #: lib/Log/Report/Util.pm:14
8981 msgid "WARNING"
9082 msgstr "WAARSCHUWING"
9183
92 #: lib/Log/Report/Dispatcher.pm:304 lib/Log/Report/Dispatcher.pm:316
84 #: lib/Log/Report.pm:268
85 msgid "a message object is reported with more parameters"
86 msgstr "een message object vergezeld van meer parameters"
87
88 #: lib/Log/Report/Dispatcher.pm:303 lib/Log/Report/Dispatcher.pm:313
9389 msgid "at {filename} line {line}"
9490 msgstr "in {filename} regel {line}"
9591
96 #: lib/Log/Report/Extract/PerlPPI.pm:70
92 #: lib/Log/Report/Extract.pm:50
9793 msgid "cannot create lexicon directory {dir}"
9894 msgstr "kan lexicon map {dir} niet aanmaken"
95
96 #: bin/xgettext-perl:60
97 msgid "cannot create output directory {dir}"
98 msgstr "uitvoer map {dir} kan niet worden aangemaakt"
9999
100100 #: lib/Log/Report/Dispatcher/Log4perl.pm:121
101101 msgid "cannot find logger '{name}' in configuration {config}"
102102 msgstr "kan logger '{name}' in configuratie {config} niet vinden"
103103
104 #: lib/Log/Report/Extract/PerlPPI.pm:115
104 #: bin/xgettext-perl:68
105 msgid "cannot read filename list from {fn}"
106 msgstr "lijst met filenamen {fn} kan niet worden gelezen"
107
108 #: lib/Log/Report/Extract/PerlPPI.pm:69
105109 msgid "cannot read from file {filename}"
106110 msgstr "kan bestand {filename} niet lezen"
107111
109113 msgid "cannot read in {cs} from file {fn}"
110114 msgstr "kan bestand {fn} niet lezen in {cs}"
111115
112 #: lib/Log/Report/Dispatcher/File.pm:92
116 #: lib/Log/Report/Extract/Template.pm:92
117 msgid "cannot read template from {fn}"
118 msgstr "template {fn} kan niet worden gelezen"
119
120 #: lib/Log/Report/Dispatcher/File.pm:96
113121 msgid "cannot write log into {file} with {binmode}"
114122 msgstr "kan log niet naar bestand {file} schrijven in {binmode}"
115123
125133 msgid "charset parameter required for {fn}"
126134 msgstr ""
127135
128 #: lib/Log/Report/Dispatcher/File.pm:81
136 #: lib/Log/Report/Dispatcher/Callback.pm:62
137 msgid "dispatcher {name} needs a 'callback'"
138 msgstr "dispatcher {name} verlangt een 'callback'"
139
140 #: lib/Log/Report/Dispatcher/File.pm:85
129141 msgid "dispatcher {name} needs parameter 'to'"
130 msgstr "dispatcher {name} verwacht argument 'to'"
131
132 #: lib/Log/Report/Extract/PerlPPI.pm:200
142 msgstr "dispatcher {name} verlangt argument 'to'"
143
144 #: bin/xgettext-perl:65
145 msgid "do not combine command-line filenames with --files-from"
146 msgstr "combineer filenamen op de commando-regel niet met --files-from"
147
148 #: lib/Log/Report/Extract/PerlPPI.pm:170
133149 msgid "do not interpolate in msgid (found '{var}' in line {line})"
134150 msgstr "gebruik geen variabelen in een msgid (vond '{var}' op regel {line'})"
135151
145161 "de regel op {where} wordt niet begrepen:\n"
146162 " {line}"
147163
164 #: lib/Log/Report.pm:654
165 msgid "even length parameter list for __x at {where}"
166 msgstr "een even-lengte lijst van parameters bij __x bij {where}"
167
168 #: bin/xgettext-perl:57
169 msgid "explicit output directory (-p) required"
170 msgstr "expliciete uitvoer map (met -p) verplicht"
171
172 #: lib/Log/Report/Extract.pm:47
173 msgid "extractions require an explicit lexicon directory"
174 msgstr "een expliciete lexicon directory is nodig voor de uittreksels"
175
148176 #: lib/Log/Report/Lexicon/POT.pm:163 lib/Log/Report/Lexicon/POTcompact.pm:106
149177 msgid "failed reading from file {fn}"
150178 msgstr "lezen uit bestand {fn} mislukt"
151179
152 #: lib/Log/Report/Extract/PerlPPI.pm:322
180 #: lib/Log/Report/Extract.pm:199
153181 msgid "found one pot file for domain {domain}"
154182 msgid_plural "found {_count} pot files for domain {domain}"
155183 msgstr[0] "één pot bestand voor domein {domain} gevonden"
159187 msgid "illegal format_reason '{format}' for dispatcher"
160188 msgstr "onbekende format_reason '{format}' voor dispatcher"
161189
162 #~ msgid "in SCALAR context, only one dispatcher name accepted"
163 #~ msgstr "in SCALAR context kan slechts één dispatcher naam worden gebruikt"
164
165190 #: lib/Log/Report/Lexicon/POTcompact.pm:182
166191 msgid "invalid plural-form algorithm '{alg}'"
167192 msgstr "incorrect meervoudsvorm algoritme '{alg}'"
168193
169 #: lib/Log/Report/Extract/PerlPPI.pm:218
194 #: lib/Log/Report/Exception.pm:102
195 msgid "message() of exception expects Log::Report::Message"
196 msgstr "message() van een exception verwacht een Log::Report::Message"
197
198 #: lib/Log/Report/Extract/Template.pm:102
199 msgid "need pattern to scan for, either via new() or process()"
200 msgstr "een scan pattern is nodig, via new() of process()"
201
202 #: lib/Log/Report/Extract/PerlPPI.pm:188
170203 msgid "new-line is added automatically (found in line {line})"
171204 msgstr "een regel-overgang wordt automatisch toegevoegd (gevonden op regel {line})"
205
206 #: lib/Log/Report/Extract/PerlPPI.pm:73
207 #, fuzzy
208 msgid "no Perl in file {filename}"
209 msgstr ""
172210
173211 #: lib/Log/Report/Lexicon/POT.pm:187
174212 msgid "no filename or file-handle specified for PO"
186224 msgid "no plurals for '{msgid}'"
187225 msgstr "geen meervoudsvormen voor '{msgid}'"
188226
189 #: lib/Log/Report/Extract/PerlPPI.pm:155
190 msgid "no textdomain for translatable at {fn} line {line}"
191 msgstr "geen textdomain voor vertaling in {fn} regel {line}"
192
193 #: lib/Log/Report.pm:489
227 #: lib/Log/Report/Extract/PerlPPI.pm:121
228 msgid "no text-domain for translatable at {fn} line {line}"
229 msgstr "geen text-domain voor vertaalbare string in {fn} regel {line}"
230
231 #: lib/Log/Report.pm:505
194232 msgid "odd length parameter list for try(): forgot the terminating ';'?"
195233 msgstr "oneven lengte van parameterlijst voor try(): afsluitende ';' vergeten?"
196234
197 #: lib/Log/Report.pm:416
235 #: lib/Log/Report.pm:276
236 msgid "odd length parameter list with '{msg}'"
237 msgstr "parameter-lijst van oneven lengte bij '{msg}'"
238
239 #: lib/Log/Report.pm:432
198240 msgid "only one dispatcher name accepted in SCALAR context"
199241 msgstr "dispatcher gebruik in SCALAR context accepteert slechts één naam"
200242
201 #: lib/Log/Report.pm:914
243 #: lib/Log/Report.pm:939
202244 msgid "only one package can contain configuration; for {domain} already in {pkg} in file {fn} line {line}"
203245 msgstr "slechts één package mag configuratie informatie bevatten; voor {domain} is dit al gevonden in {pkg}, bestand {fn} regel {line}"
204246
205 #: lib/Log/Report/Extract/PerlPPI.pm:109
247 #: lib/Log/Report/Extract/PerlPPI.pm:77 lib/Log/Report/Extract/Template.pm:87
206248 msgid "processing file {fn} in {charset}"
207249 msgstr "verwerk bestand {fn} in {charset}"
250
251 #: bin/xgettext-perl:54
252 msgid "programming language {lang} not supported"
253 msgstr "programmeertaal {lang} wordt niet ondersteund"
208254
209255 #: lib/Log/Report/Lexicon/PO.pm:360
210256 msgid "quoted line is not a continuation at {where}"
218264 msgid "reason '{begin}' more serious than '{end}' in '{reasons}"
219265 msgstr "reden '{begin}' is serieuzer dan '{end}' in '{reasons}'"
220266
221 #: lib/Log/Report/Extract/PerlPPI.pm:330
267 #: lib/Log/Report/Extract/Template.pm:186
268 msgid "scan pattern `{pattern}' not recognized"
269 msgstr "scan patroon `{pattern}' wordt niet herkend"
270
271 #: lib/Log/Report/Extract.pm:208
222272 msgid "starting new textdomain {domain}, template in {filename}"
223273 msgstr "begin van nieuw textdomain {domain}, sjabloon in {filename}"
224274
226276 msgid "string '{text}' not between quotes at {location}"
227277 msgstr "tekst '{text}' niet tussen quotes in {location}"
228278
229 #: lib/Log/Report/Extract/PerlPPI.pm:208
279 #: lib/Log/Report/Extract/PerlPPI.pm:178
230280 msgid "string is incorrect at line {line}: {error}"
231281 msgstr "foutieve string in regel {regel}: {error}"
232282
234284 msgid "switching to run mode {mode}, accept {accept}"
235285 msgstr "verwerkingsmode {mode}, accepteert {accept}"
236286
237 #: lib/Log/Report.pm:842
287 #: lib/Log/Report.pm:867
238288 msgid "syntax flag must be either SHORT or REPORT, not `{syntax}'"
239289 msgstr "syntax parameter moet zijn SHORT of REPORT, niet `{syntax}'"
240290
242292 msgid "syslog level '{level}' not understood"
243293 msgstr "syslog level '{level}' niet herkend"
244294
245 #: lib/Log/Report.pm:882
295 #: lib/Log/Report.pm:907
246296 msgid "textdomain for translator not defined"
247297 msgstr "tekstdomein voor vertaler niet gedefinieerd"
248298
250300 msgid "textdomain parameter is required"
251301 msgstr "tekstdomain argument is verplicht"
252302
253 #: lib/Log/Report.pm:402
303 #: lib/Log/Report.pm:417
254304 msgid "the 'filter' sub-command needs a CODE reference"
255305 msgstr "het 'filter' sub-commando verwacht een CODE referentie"
256306
257 #: lib/Log/Report.pm:389
307 #: lib/Log/Report.pm:404
258308 msgid "the 'list' sub-command doesn't expect additional parameters"
259309 msgstr "het 'list' sub-commando verwacht geen aanvullende argumenten"
260310
261 #: lib/Log/Report.pm:395
311 #: lib/Log/Report.pm:410
262312 msgid "the 'needs' sub-command parameter '{reason}' is not a reason"
263313 msgstr "het 'needs' sub-commando argument '{reason}' is geen reden"
264314
266316 msgid "the only acceptable parameter is 'ACTIVE', not '{p}'"
267317 msgstr "het enige geaccepteerde argument is 'ACTIVE', niet '{p}'"
268318
319 #: lib/Log/Report.pm:245
320 msgid "token '{token}' not recognized as reason"
321 msgstr "token '{token}' niet herkend als reden"
322
269323 #: lib/Log/Report/Lexicon/PO.pm:435
270324 msgid "too many plurals for '{msgid}'"
271325 msgstr "te veel meervouden voor '{msgid}'"
274328 msgid "translation already exists for '{msgid}'"
275329 msgstr "er bestaat al een vertaling voor '{msgid}'"
276330
277 #: lib/Log/Report.pm:889
331 #: lib/Log/Report.pm:914
278332 msgid "translator must be a Log::Report::Translator object"
279333 msgstr "vertaler moet een Log::Report::Translator object zijn"
280334
281 #: lib/Log/Report/Dispatcher/Try.pm:216
335 #: lib/Log/Report/Dispatcher/Try.pm:220
282336 msgid "try-block stopped with {reason}: {text}"
283337 msgstr "try-blok gestopt met {reason}: {text}"
284338
306360 msgid "unnamed file"
307361 msgstr "naamloze file"
308362
309 #: lib/Log/Report.pm:919
363 #: lib/Log/Report.pm:944
310364 msgid "value for {name} specified twice"
311365 msgstr "twee keer een waarde voor {name}"
312366
314368 msgid "write errors for file {fn}"
315369 msgstr "schrijfproblemen bij bestand {fn}"
316370
317 #: lib/Log/Report/Extract/PerlPPI.pm:270
371 #: lib/Log/Report/Extract.pm:146
318372 msgid "{domain}: one file with {ids} msgids"
319373 msgid_plural "{domain}: {_count} files with each {ids} msgids"
320374 msgstr[0] "{domain}: één bestand met {ids} mgsids"
321375 msgstr[1] "{domain}: {_count} bestanden met elk {ids} msgids"
322376
323 #: lib/Log/Report/Extract/PerlPPI.pm:263
377 #: lib/Log/Report/Extract.pm:139
324378 msgid "{domain}: one file with {ids} msgids, {f} fuzzy and {i} inactive translations"
325379 msgid_plural "{domain}: {_count} files each {ids} msgids, {f} fuzzy and {i} inactive translations in total"
326380 msgstr[0] "{domain}: één bestand met {ids} mgsids, {f} fuzzy en {i} op non-actief"
327381 msgstr[1] "{domain}: {_count} bestanden met elk {ids} msgids, {f} fuzzy en {i} op non-actief in het totaal"
328382
329 #: lib/Log/Report/Extract/PerlPPI.pm:253
383 #: lib/Log/Report/Extract.pm:129
330384 msgid "{domain}: {fuzzy%3d} fuzzy, {inact%3d} inactive in {filename}"
331385 msgstr "{domain}: {fuzzy%3d} fuzzy, {inact%3d} op non-actief in {filename}"
332386
33 "Project-Id-Version: log-report 0.01\n"
44 "Report-Msgid-Bugs-To:\n"
55 "POT-Creation-Date: 2007-05-14 17:14+0200\n"
6 "PO-Revision-Date: 2009-04-27 09:47+0200\n"
6 "PO-Revision-Date: 2012-08-30 21:52+0200\n"
77 "Last-Translator:\n"
88 "Language-Team:\n"
99 "MIME-Version: 1.0\n"
8080 msgid "PANIC"
8181 msgstr ""
8282
83 #: lib/Log/Report/Extract/PerlPPI.pm:112
83 #: lib/Log/Report/Extract/PerlPPI.pm:66
8484 #, fuzzy
8585 msgid "PPI only supports iso-8859-1 (latin-1) on the moment"
8686 msgstr ""
9090 msgid "Perl does not support charset {cs}"
9191 msgstr ""
9292
93 #: lib/Log/Report/Extract/PerlPPI.pm:67
94 #, fuzzy
95 msgid "PerlPPI requires explicit lexicon directory"
96 msgstr ""
97
9893 #: lib/Log/Report/Util.pm:14
9994 #, fuzzy
10095 msgid "TRACE"
10196 msgstr ""
10297
103 #: lib/Log/Report.pm:225
104 #, fuzzy
105 msgid "Token '{token}' not recognized as reason"
106 msgstr ""
107
10898 #: lib/Log/Report/Util.pm:14
10999 #, fuzzy
110100 msgid "WARNING"
111101 msgstr ""
112102
113 #: lib/Log/Report/Dispatcher.pm:304 lib/Log/Report/Dispatcher.pm:316
103 #: lib/Log/Report.pm:268
104 #, fuzzy
105 msgid "a message object is reported with more parameters"
106 msgstr ""
107
108 #: lib/Log/Report/Dispatcher.pm:303 lib/Log/Report/Dispatcher.pm:313
114109 #, fuzzy
115110 msgid "at {filename} line {line}"
116111 msgstr ""
117112
118 #: lib/Log/Report/Extract/PerlPPI.pm:70
113 #: lib/Log/Report/Extract.pm:50
119114 #, fuzzy
120115 msgid "cannot create lexicon directory {dir}"
121116 msgstr ""
122117
118 #: bin/xgettext-perl:60
119 #, fuzzy
120 msgid "cannot create output directory {dir}"
121 msgstr ""
122
123123 #: lib/Log/Report/Dispatcher/Log4perl.pm:121
124124 #, fuzzy
125125 msgid "cannot find logger '{name}' in configuration {config}"
126126 msgstr ""
127127
128 #: lib/Log/Report/Extract/PerlPPI.pm:115
128 #: bin/xgettext-perl:68
129 #, fuzzy
130 msgid "cannot read filename list from {fn}"
131 msgstr ""
132
133 #: lib/Log/Report/Extract/PerlPPI.pm:69
129134 #, fuzzy
130135 msgid "cannot read from file {filename}"
131136 msgstr ""
135140 msgid "cannot read in {cs} from file {fn}"
136141 msgstr ""
137142
138 #: lib/Log/Report/Dispatcher/File.pm:92
143 #: lib/Log/Report/Extract/Template.pm:92
144 #, fuzzy
145 msgid "cannot read template from {fn}"
146 msgstr ""
147
148 #: lib/Log/Report/Dispatcher/File.pm:96
139149 #, fuzzy
140150 msgid "cannot write log into {file} with {binmode}"
141151 msgstr ""
155165 msgid "charset parameter required for {fn}"
156166 msgstr ""
157167
158 #: lib/Log/Report/Dispatcher/File.pm:81
168 #: lib/Log/Report/Dispatcher/Callback.pm:62
169 #, fuzzy
170 msgid "dispatcher {name} needs a 'callback'"
171 msgstr ""
172
173 #: lib/Log/Report/Dispatcher/File.pm:85
159174 #, fuzzy
160175 msgid "dispatcher {name} needs parameter 'to'"
161176 msgstr ""
162177
163 #: lib/Log/Report/Extract/PerlPPI.pm:200
178 #: bin/xgettext-perl:65
179 #, fuzzy
180 msgid "do not combine command-line filenames with --files-from"
181 msgstr ""
182
183 #: lib/Log/Report/Extract/PerlPPI.pm:170
164184 #, fuzzy
165185 msgid "do not interpolate in msgid (found '{var}' in line {line})"
166186 msgstr ""
177197 " {line}"
178198 msgstr ""
179199
200 #: lib/Log/Report.pm:654
201 #, fuzzy
202 msgid "even length parameter list for __x at {where}"
203 msgstr ""
204
205 #: bin/xgettext-perl:57
206 #, fuzzy
207 msgid "explicit output directory (-p) required"
208 msgstr ""
209
210 #: lib/Log/Report/Extract.pm:47
211 #, fuzzy
212 msgid "extractions require an explicit lexicon directory"
213 msgstr ""
214
180215 #: lib/Log/Report/Lexicon/POT.pm:163 lib/Log/Report/Lexicon/POTcompact.pm:106
181216 #, fuzzy
182217 msgid "failed reading from file {fn}"
183218 msgstr ""
184219
185 #: lib/Log/Report/Extract/PerlPPI.pm:322
220 #: lib/Log/Report/Extract.pm:199
186221 #, fuzzy
187222 msgid "found one pot file for domain {domain}"
188223 msgid_plural "found {_count} pot files for domain {domain}"
199234 msgid "invalid plural-form algorithm '{alg}'"
200235 msgstr ""
201236
202 #: lib/Log/Report/Extract/PerlPPI.pm:218
237 #: lib/Log/Report/Exception.pm:102
238 #, fuzzy
239 msgid "message() of exception expects Log::Report::Message"
240 msgstr ""
241
242 #: lib/Log/Report/Extract/Template.pm:102
243 #, fuzzy
244 msgid "need pattern to scan for, either via new() or process()"
245 msgstr ""
246
247 #: lib/Log/Report/Extract/PerlPPI.pm:188
203248 #, fuzzy
204249 msgid "new-line is added automatically (found in line {line})"
205250 msgstr ""
206251
252 #: lib/Log/Report/Extract/PerlPPI.pm:73
253 #, fuzzy
254 msgid "no Perl in file {filename}"
255 msgstr ""
256
207257 #: lib/Log/Report/Lexicon/POT.pm:187
208258 #, fuzzy
209259 msgid "no filename or file-handle specified for PO"
224274 msgid "no plurals for '{msgid}'"
225275 msgstr ""
226276
227 #: lib/Log/Report/Extract/PerlPPI.pm:155
228 #, fuzzy
229 msgid "no textdomain for translatable at {fn} line {line}"
230 msgstr ""
231
232 #: lib/Log/Report.pm:489
277 #: lib/Log/Report/Extract/PerlPPI.pm:121
278 #, fuzzy
279 msgid "no text-domain for translatable at {fn} line {line}"
280 msgstr ""
281
282 #: lib/Log/Report.pm:505
233283 #, fuzzy
234284 msgid "odd length parameter list for try(): forgot the terminating ';'?"
235285 msgstr ""
236286
237 #: lib/Log/Report.pm:416
287 #: lib/Log/Report.pm:276
288 #, fuzzy
289 msgid "odd length parameter list with '{msg}'"
290 msgstr ""
291
292 #: lib/Log/Report.pm:432
238293 #, fuzzy
239294 msgid "only one dispatcher name accepted in SCALAR context"
240295 msgstr ""
241296
297 #: lib/Log/Report.pm:939
298 #, fuzzy
299 msgid "only one package can contain configuration; for {domain} already in {pkg} in file {fn} line {line}"
300 msgstr ""
301
302 #: lib/Log/Report/Extract/PerlPPI.pm:77 lib/Log/Report/Extract/Template.pm:87
303 #, fuzzy
304 msgid "processing file {fn} in {charset}"
305 msgstr ""
306
307 #: bin/xgettext-perl:54
308 #, fuzzy
309 msgid "programming language {lang} not supported"
310 msgstr ""
311
312 #: lib/Log/Report/Lexicon/PO.pm:360
313 #, fuzzy
314 msgid "quoted line is not a continuation at {where}"
315 msgstr ""
316
317 #: lib/Log/Report/Translator/POT.pm:85
318 #, fuzzy
319 msgid "read pot-file {filename} for {domain} in {locale}"
320 msgstr ""
321
322 #: lib/Log/Report/Util.pm:136
323 #, fuzzy
324 msgid "reason '{begin}' more serious than '{end}' in '{reasons}"
325 msgstr ""
326
327 #: lib/Log/Report/Extract/Template.pm:186
328 #, fuzzy
329 msgid "scan pattern `{pattern}' not recognized"
330 msgstr ""
331
332 #: lib/Log/Report/Extract.pm:208
333 #, fuzzy
334 msgid "starting new textdomain {domain}, template in {filename}"
335 msgstr ""
336
337 #: lib/Log/Report/Lexicon/POTcompact.pm:194
338 #, fuzzy
339 msgid "string '{text}' not between quotes at {location}"
340 msgstr ""
341
342 #: lib/Log/Report/Extract/PerlPPI.pm:178
343 #, fuzzy
344 msgid "string is incorrect at line {line}: {error}"
345 msgstr ""
346
347 #: lib/Log/Report/Dispatcher.pm:215
348 #, fuzzy
349 msgid "switching to run mode {mode}, accept {accept}"
350 msgstr ""
351
352 #: lib/Log/Report.pm:867
353 #, fuzzy
354 msgid "syntax flag must be either SHORT or REPORT, not `{syntax}'"
355 msgstr ""
356
357 #: lib/Log/Report/Dispatcher/Syslog.pm:122
358 #, fuzzy
359 msgid "syslog level '{level}' not understood"
360 msgstr ""
361
362 #: lib/Log/Report.pm:907
363 #, fuzzy
364 msgid "textdomain for translator not defined"
365 msgstr ""
366
367 #: lib/Log/Report/Lexicon/POT.pm:112
368 #, fuzzy
369 msgid "textdomain parameter is required"
370 msgstr ""
371
372 #: lib/Log/Report.pm:417
373 #, fuzzy
374 msgid "the 'filter' sub-command needs a CODE reference"
375 msgstr ""
376
377 #: lib/Log/Report.pm:404
378 #, fuzzy
379 msgid "the 'list' sub-command doesn't expect additional parameters"
380 msgstr ""
381
382 #: lib/Log/Report.pm:410
383 #, fuzzy
384 msgid "the 'needs' sub-command parameter '{reason}' is not a reason"
385 msgstr ""
386
387 #: lib/Log/Report/Lexicon/POT.pm:286
388 #, fuzzy
389 msgid "the only acceptable parameter is 'ACTIVE', not '{p}'"
390 msgstr ""
391
392 #: lib/Log/Report.pm:245
393 #, fuzzy
394 msgid "token '{token}' not recognized as reason"
395 msgstr ""
396
397 #: lib/Log/Report/Lexicon/PO.pm:435
398 #, fuzzy
399 msgid "too many plurals for '{msgid}'"
400 msgstr ""
401
402 #: lib/Log/Report/Lexicon/POT.pm:269
403 #, fuzzy
404 msgid "translation already exists for '{msgid}'"
405 msgstr ""
406
242407 #: lib/Log/Report.pm:914
243408 #, fuzzy
244 msgid "only one package can contain configuration; for {domain} already in {pkg} in file {fn} line {line}"
245 msgstr ""
246
247 #: lib/Log/Report/Extract/PerlPPI.pm:109
248 #, fuzzy
249 msgid "processing file {fn} in {charset}"
250 msgstr ""
251
252 #: lib/Log/Report/Lexicon/PO.pm:360
253 #, fuzzy
254 msgid "quoted line is not a continuation at {where}"
255 msgstr ""
256
257 #: lib/Log/Report/Translator/POT.pm:85
258 #, fuzzy
259 msgid "read pot-file {filename} for {domain} in {locale}"
260 msgstr ""
261
262 #: lib/Log/Report/Util.pm:136
263 #, fuzzy
264 msgid "reason '{begin}' more serious than '{end}' in '{reasons}"
265 msgstr ""
266
267 #: lib/Log/Report/Extract/PerlPPI.pm:330
268 #, fuzzy
269 msgid "starting new textdomain {domain}, template in {filename}"
270 msgstr ""
271
272 #: lib/Log/Report/Lexicon/POTcompact.pm:194
273 #, fuzzy
274 msgid "string '{text}' not between quotes at {location}"
275 msgstr ""
276
277 #: lib/Log/Report/Extract/PerlPPI.pm:208
278 #, fuzzy
279 msgid "string is incorrect at line {line}: {error}"
280 msgstr ""
281
282 #: lib/Log/Report/Dispatcher.pm:215
283 #, fuzzy
284 msgid "switching to run mode {mode}, accept {accept}"
285 msgstr ""
286
287 #: lib/Log/Report.pm:842
288 #, fuzzy
289 msgid "syntax flag must be either SHORT or REPORT, not `{syntax}'"
290 msgstr ""
291
292 #: lib/Log/Report/Dispatcher/Syslog.pm:122
293 #, fuzzy
294 msgid "syslog level '{level}' not understood"
295 msgstr ""
296
297 #: lib/Log/Report.pm:882
298 #, fuzzy
299 msgid "textdomain for translator not defined"
300 msgstr ""
301
302 #: lib/Log/Report/Lexicon/POT.pm:112
303 #, fuzzy
304 msgid "textdomain parameter is required"
305 msgstr ""
306
307 #: lib/Log/Report.pm:402
308 #, fuzzy
309 msgid "the 'filter' sub-command needs a CODE reference"
310 msgstr ""
311
312 #: lib/Log/Report.pm:389
313 #, fuzzy
314 msgid "the 'list' sub-command doesn't expect additional parameters"
315 msgstr ""
316
317 #: lib/Log/Report.pm:395
318 #, fuzzy
319 msgid "the 'needs' sub-command parameter '{reason}' is not a reason"
320 msgstr ""
321
322 #: lib/Log/Report/Lexicon/POT.pm:286
323 #, fuzzy
324 msgid "the only acceptable parameter is 'ACTIVE', not '{p}'"
325 msgstr ""
326
327 #: lib/Log/Report/Lexicon/PO.pm:435
328 #, fuzzy
329 msgid "too many plurals for '{msgid}'"
330 msgstr ""
331
332 #: lib/Log/Report/Lexicon/POT.pm:269
333 #, fuzzy
334 msgid "translation already exists for '{msgid}'"
335 msgstr ""
336
337 #: lib/Log/Report.pm:889
338 #, fuzzy
339409 msgid "translator must be a Log::Report::Translator object"
340410 msgstr ""
341411
342 #: lib/Log/Report/Dispatcher/Try.pm:216
412 #: lib/Log/Report/Dispatcher/Try.pm:220
343413 #, fuzzy
344414 msgid "try-block stopped with {reason}: {text}"
345415 msgstr ""
374444 msgid "unnamed file"
375445 msgstr ""
376446
377 #: lib/Log/Report.pm:919
447 #: lib/Log/Report.pm:944
378448 #, fuzzy
379449 msgid "value for {name} specified twice"
380450 msgstr ""
384454 msgid "write errors for file {fn}"
385455 msgstr ""
386456
387 #: lib/Log/Report/Extract/PerlPPI.pm:270
457 #: lib/Log/Report/Extract.pm:146
388458 #, fuzzy
389459 msgid "{domain}: one file with {ids} msgids"
390460 msgid_plural "{domain}: {_count} files with each {ids} msgids"
391461 msgstr[0] ""
392462 msgstr[1] ""
393463
394 #: lib/Log/Report/Extract/PerlPPI.pm:263
464 #: lib/Log/Report/Extract.pm:139
395465 #, fuzzy
396466 msgid "{domain}: one file with {ids} msgids, {f} fuzzy and {i} inactive translations"
397467 msgid_plural "{domain}: {_count} files each {ids} msgids, {f} fuzzy and {i} inactive translations in total"
398468 msgstr[0] ""
399469 msgstr[1] ""
400470
401 #: lib/Log/Report/Extract/PerlPPI.pm:253
471 #: lib/Log/Report/Extract.pm:129
402472 #, fuzzy
403473 msgid "{domain}: {fuzzy%3d} fuzzy, {inact%3d} inactive in {filename}"
404474 msgstr ""
5252 dispatcher PERL => 'default', accept => 'NOTICE-';
5353
5454 =chapter NAME
55 Log::Report - report a problem, pluggable handlers and language support
55 Log::Report - report a problem, with exceptions and language support
5656
5757 =chapter SYNOPSIS
58 # Read section "The Reason for the report" first!!!
59
60 # In each package, declare a name-space. Different packages
61 # used by one program can have different translation tables.
58 # Invocation with mode helps debugging
59 use Log::Report mode => 'DEBUG';
60
61 -f $config or panic "Help!"; # alert/error/fault/info/...more
62 error "oops"; # like die(), no translation
63
64 # Provide a name-space to use translation tables. Like Locale::TextDomain
6265 use Log::Report 'my-domain';
63
64 # Many destinations in parallel possible. Log::Report::Dispatcher
65 dispatcher PERL => 'default'
66 , reasons => 'NOTICE-'; # this disp. is automatically added
67
68 dispatcher SYSLOG => 'syslog'
69 , charset => 'iso-8859-1' # explicit conversions
70 , locale => 'en_US'; # overrule user's locale
71
72 # Produce an error, long syntax
66 error __x"Help!"; # __x() handles translation
67 print __x"my name is {name}", name => $fullname;
68 print __x'Hello World'; # ERROR!! ' is alternative for ::
69
70 # Many destinations for message in parallel possible.
71 dispatcher PERL => 'default' # See Log::Report::Dispatcher: use die/warn
72 , reasons => 'NOTICE-'; # this disp. is already present at start
73
74 dispatcher SYSLOG => 'syslog'# also send to syslog
75 , charset => 'iso-8859-1' # explicit character conversions
76 , locale => 'en_US'; # overrule user's locale
77
78 dispatcher close => 'PERL'; # stop dispatching to die/warn
79
80 # Produce an error, long syntax (rarely used)
7381 report ERROR => __x('gettext string', param => $param, ...)
7482 if $condition;
7583
76 # when syntax=SHORT (default since 0.26), many useful functions
84 # When syntax=SHORT (default since 0.26)
7785 error __x('gettext string', param => $param, ...)
7886 if $condition;
7987
8492 report {to => 'syslog', errno => ENOMEM}
8593 , FAULT => __x"cannot allocate {size} bytes", size => $size;
8694
87 # avoid messages without report level for daemons
95 # Avoid messages without report level for daemons
8896 print __"Hello World", "\n"; # only translation, no exception
89 print __'Hello World'; # ERROR!! ' is alternative for ::
9097
9198 # fill-in values, like Locale::TextDomain and gettext
9299 # See Log::Report::Message section DETAILS
101108 if($@) {...} # $@ isa Log::Report::Dispatcher::Try
102109
103110 # Language translations at the IO/layer
104 use POSIX ':locale_h';
111 use POSIX::1003::Locale qw/setlocale LC_ALL/;
105112 setlocale(LC_ALL, 'nl_NL');
106 info __"Hello World!"; # in Dutch, if translation table found
113 info __"Hello World!"; # in Dutch, if translation table found
107114
108115 # Exception classes, see Log::Report::Exception
109 my $msg = __x"something", _class => 'local,mine';
110 if($msg->inClass('local')) ...
116 my $msg = __x"something", _class => 'parsing,schema';
117 if($msg->inClass('parsing')) ...
111118
112119 =chapter DESCRIPTION
113120 Handling messages to users can be a hassle, certainly when the same
265272 }
266273 else
267274 { # untranslated message into object
268 @_%2 and error __x"odd length parameter list with '$message'";
275 @_%2 and error __x"odd length parameter list with '{msg}'", msg => $message;
269276 $message = Log::Report::Message->new(_prepend => $message, @_);
270277 }
271278
789796 =option translator Log::Report::Translator
790797 =default translator <rescue>
791798 Without explicit translator, a dummy translator is used for the domain
792 which will use the untranslated message-id .
799 which will use the untranslated message-id.
793800
794801 =option native_language CODESET
795802 =default native_language 'en_US'
810817 use Log::Report 'my-domain'; # in each package producing messages
811818
812819 use Log::Report 'my-domain' # in one package, top of distr
813 , translator => Log::Report::Translator::POT->new
814 ( lexicon => '/home/me/locale' # bindtextdomain
815 , charset => 'UTF-8' # codeset
820 , mode => 'VERBOSE'
821 , translator => Log::Report::Translator::POT->new
822 ( lexicon => '/home/me/locale' # bindtextdomain
823 , charset => 'UTF-8' # codeset
816824 )
817825 , native_language => 'nl_NL' # untranslated msgs are Dutch
818826 , syntax => 'REPORT';# report ERROR, not error()
851859
852860 my @export = (@functions, @make_msg);
853861
854 if($syntax eq 'SHORT') { push @export, @reason_functions }
862 if($syntax eq 'SHORT')
863 { push @export, @reason_functions
864 }
855865 elsif($syntax ne 'REPORT' && $syntax ne 'LONG')
856866 { error __x"syntax flag must be either SHORT or REPORT, not `{syntax}'"
857867 , syntax => $syntax;
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 use warnings;
22 use strict;
3 use lib 'lib', '../lib';
43
5 use Test::More tests => 16;
4 use Test::More tests => 18;
65
76 # The versions of the following packages are reported to help understanding
87 # the environment in which the tests are run. This is certainly not a
3635 use_ok('Log::Report::Dispatcher::Perl');
3736 use_ok('Log::Report::Dispatcher::Callback');
3837 use_ok('Log::Report::Exception');
38 use_ok('Log::Report::Extract');
39 use_ok('Log::Report::Extract::Template');
3940 use_ok('Log::Report::Lexicon::Index');
4041 use_ok('Log::Report::Lexicon::PO');
4142 use_ok('Log::Report::Lexicon::POT');
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # test locale
22
33 use Test::More;
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 use warnings;
22 use strict;
3 use lib 'lib', '../lib';
43
54 use Test::More tests => 53;
65
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Try __
22
33 use warnings;
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Try concatenation
22
33 use warnings;
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Try Lexicon POT
22
33 use warnings;
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Try Lexicon PO modifications
22
33 use warnings;
44 use strict;
5 use lib 'lib', '../lib';
65 use utf8;
76
87 use Test::More tests => 29;
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Try Lexicon POTcompact
22 # Structure of parsed result has also been checked manually, using
33 # Data::Dumper (MO 2007/05/11)
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # test the lexicon index.
22
33 use warnings;
44 use strict;
5 use lib 'lib', '../lib';
65
76 use Test::More;
87
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # test the lexicon index.
22
33 use warnings;
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Try Extract PPI
22
33 use warnings;
44 use strict;
5 use lib 'lib', '../lib';
65
76 use File::Temp qw/tempdir/;
87 use Test::More;
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Convert die into report
22
33 use warnings;
44 use strict;
5 use lib 'lib', '../lib', 't';
5 use lib 't';
66
77 use POSIX;
88
0 #!/usr/bin/env perl
1 # Try Extract templates
2
3 use warnings;
4 use strict;
5
6 use File::Temp qw/tempdir/;
7
8 use Test::More;
9
10 use Log::Report; # mode => 'DEBUG';
11 use Log::Report::Lexicon::POT;
12 use Log::Report::Extract::Template;
13
14 use constant MSGIDS => 5;
15
16 # see after __END__
17 my @expect_pos = split /\n/, <<'_EXPECT';
18 first
19 second
20 third
21 fourth
22 fifth
23 _EXPECT
24
25 chomp $expect_pos[-1];
26 cmp_ok(scalar @expect_pos, '==', MSGIDS);
27 my %expect_pos = map { ($_ => 1) } @expect_pos;
28 $expect_pos{''} = 1; # header
29
30 BEGIN {
31 plan tests => 15 + MSGIDS*3;
32 }
33
34 my $lexicon = tempdir CLEANUP => 1;
35
36 my $extr = Log::Report::Extract::Template->new
37 ( lexicon => $lexicon
38 , domain => 'my-domain'
39 , pattern => 'TT2-loc'
40 );
41
42 ok(defined $extr, 'created parser');
43 isa_ok($extr, 'Log::Report::Extract::Template');
44
45 my $found = $extr->process( __FILE__ ); # yes, this file!
46 cmp_ok($found, '==', MSGIDS);
47
48 $extr->write;
49
50 my @potfns = $extr->index->list('my-domain');
51 cmp_ok(scalar @potfns, '==', 1, "one file created");
52 my $potfn = shift @potfns;
53 ok(defined $potfn);
54 ok(-s $potfn, "produced file $potfn has size");
55
56 #system "cat $potfn";
57
58 #
59
60 my $pot = Log::Report::Lexicon::POT->read($potfn, charset => 'utf-8');
61 ok(defined $pot, 'read translation table');
62 my @pos = $pot->translations('ACTIVE');
63 ok(@pos > 0);
64
65 # (+1 for the header)
66 cmp_ok(scalar @pos, '==', MSGIDS+1, 'correct number tests');
67 cmp_ok(scalar @pos, '==', scalar $pot->translations); # all active
68
69 my %msgids;
70 for my $po (@pos)
71 { my $msgid = $po->msgid;
72 ok(defined $msgid, "processing '$msgid'");
73 ok(!defined $msgids{$msgid}, 'check not double');
74 $msgids{$msgid}++;
75 ok(delete $expect_pos{$msgid}, 'was expected');
76 }
77
78 cmp_ok(scalar keys %expect_pos, '==', 0, "all msgids found");
79 warn "NOT FOUND: $_\n" for keys %expect_pos;
80
81 __END__
82 Here, the example template starts
83 [%loc("first")%]
84 [%loc("second")%]
85 [%loc('third')%]
86 [% loc ( 'fourth' ) %]
87 [%
88 loc
89 (
90 'fifth'
91 , params
92 )
93 %]
94 [%xloc('not found')%]
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # test the file back-end, without translations
22
33 use warnings;
44 use strict;
5 use lib 'lib', '../lib';
65
76 use Test::More tests => 38;
87
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Test syslog, but only mildly
22
33 use warnings;
44 use strict;
5 use lib 'lib', '../lib';
65
76 use Test::More;
8
97 use Log::Report undef, syntax => 'SHORT';
108
119 BEGIN
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Test Log::Dispatch (only very simple tests)
22
33 use warnings;
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Test Log::Log4perl (only very simple tests)
22
33 use warnings;
44 use strict;
5 use lib 'lib', '../lib';
65
76 use File::Temp qw/tempfile/;
87 use Test::More;
0 #!/usr/bin/perl
0 #!/usr/bin/env perl
11 # Test try()
22
33 use warnings;
44 use strict;
5 use lib 'lib', '../lib';
65
76 use Test::More tests => 49;
87
129128 my $die_ex = $@->wasFatal;
130129 isa_ok($die_ex, 'Log::Report::Exception');
131130 is($die_ex->reason, 'ERROR');
132 like("$@", qr[^try-block stopped with ERROR: oops at t/54try\.t line \d+$] );
131 like("$@", qr[^try-block stopped with ERROR: oops at ] );
133132
134133 my $croak = try { croak "oops" };
135134 ok(ref $@, 'caught croak');
137136 my $croak_ex = $@->wasFatal;
138137 isa_ok($croak_ex, 'Log::Report::Exception');
139138 is($croak_ex->reason, 'ERROR');
140 like("$@", qr[^try-block stopped with ERROR: oops at lib/Log/Report.pm line \d+$] );
139 like("$@", qr[^try-block stopped with ERROR: oops at ] );
141140
142141 my $confess = try { confess "oops" };
143142 ok(ref $@, 'caught confess');
145144 my $confess_ex = $@->wasFatal;
146145 isa_ok($confess_ex, 'Log::Report::Exception');
147146 is($confess_ex->reason, 'PANIC');
148 like("$@", qr[^try-block stopped with PANIC: oops at t/54try\.t line \d+$] );
147 like("$@", qr[^try-block stopped with PANIC: oops at ] );
+0
-15
t/99pod.t less more
0 #!/usr/bin/perl
1 use warnings;
2 use strict;
3
4 use Test::More;
5
6 BEGIN
7 { eval "use Test::Pod 1.00";
8 plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
9
10 plan skip_all => "devel home uses OODoc"
11 if $ENV{MARKOV_DEVEL};
12 }
13
14 all_pod_files_ok();
22 use strict;
33
44 use Log::Report::Die qw/die_decode/;
5 use Log::Report qw/try/;
5 use Log::Report qw/log-report/;
66 use Carp;
77
88 use Test::More tests => 27;
0 #!/usr/bin/env perl
1 use warnings;
2 use strict;
3
4 use Test::More;
5
6 BEGIN
7 { eval "use Test::Pod 1.00";
8 plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
9
10 plan skip_all => "devel home uses OODoc"
11 if $ENV{MARKOV_DEVEL};
12 }
13
14 all_pod_files_ok();