line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# mamgal - a program for creating static image galleries |
2
|
|
|
|
|
|
|
# Copyright 2007-2009 Marcin Owsiany |
3
|
|
|
|
|
|
|
# See the README file for license information |
4
|
|
|
|
|
|
|
# A logging subsystem class |
5
|
|
|
|
|
|
|
package App::MaMGal::Logger; |
6
|
1
|
|
|
1
|
|
2826
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
7
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
8
|
1
|
|
|
1
|
|
5
|
use base 'App::MaMGal::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
613
|
|
9
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
446
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub init |
12
|
|
|
|
|
|
|
{ |
13
|
6
|
|
|
6
|
0
|
137
|
my $self = shift; |
14
|
6
|
100
|
|
|
|
58
|
my $fh = shift or croak "filehandle arg required"; |
15
|
5
|
|
|
|
|
24
|
$self->{fh} = $fh; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub log_message |
19
|
|
|
|
|
|
|
{ |
20
|
21
|
|
|
21
|
0
|
1223
|
my $self = shift; |
21
|
21
|
|
|
|
|
37
|
my $msg = shift; |
22
|
21
|
|
100
|
|
|
69
|
my $prefix = shift || ''; |
23
|
21
|
100
|
|
|
|
45
|
$prefix .= ': ' if $prefix; |
24
|
21
|
|
|
|
|
203
|
$self->{fh}->printf("%s%s\n", $prefix, $msg); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our $not_available_warned_before = 0; |
28
|
|
|
|
|
|
|
our $exe_failure_warned_before = 0; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub log_exception |
31
|
|
|
|
|
|
|
{ |
32
|
11
|
|
|
11
|
0
|
626
|
my $self = shift; |
33
|
11
|
|
|
|
|
18
|
my $e = shift; |
34
|
11
|
|
|
|
|
16
|
my $prefix = shift; |
35
|
11
|
100
|
|
|
|
43
|
if ($e->isa('App::MaMGal::MplayerWrapper::NotAvailableException')) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# TODO this needs to be made thread-safe |
37
|
2
|
100
|
|
|
|
48
|
return if $not_available_warned_before; |
38
|
1
|
|
|
|
|
2
|
$not_available_warned_before = 1; |
39
|
|
|
|
|
|
|
} elsif ($e->isa('App::MaMGal::MplayerWrapper::ExecutionFailureException')) { |
40
|
|
|
|
|
|
|
# TODO this needs to be made thread-safe |
41
|
3
|
100
|
66
|
|
|
173
|
goto JUST_LOG if $exe_failure_warned_before or (! $e->stdout and ! $e->stderr); |
|
|
|
100
|
|
|
|
|
42
|
1
|
|
|
|
|
59
|
$exe_failure_warned_before = 1; |
43
|
1
|
|
|
|
|
7
|
$self->log_message($e->message, $prefix); |
44
|
1
|
|
|
|
|
53
|
$self->log_message('--------------------- standard output messages -------------------', $prefix); |
45
|
1
|
50
|
|
|
|
116
|
$self->log_message($_, $prefix) for $e->stdout ? @{$e->stdout} : (); |
|
1
|
|
|
|
|
63
|
|
46
|
1
|
|
|
|
|
54
|
$self->log_message('--------------------- standard error messages --------------------', $prefix); |
47
|
1
|
50
|
|
|
|
56
|
$self->log_message($_, $prefix) for $e->stderr ? @{$e->stderr} : (); |
|
1
|
|
|
|
|
57
|
|
48
|
1
|
|
|
|
|
53
|
$self->log_message('------------------------------------------------------------------', $prefix); |
49
|
1
|
|
|
|
|
52
|
return; |
50
|
|
|
|
|
|
|
} elsif ($e->isa('App::MaMGal::SystemException')) { |
51
|
2
|
|
|
|
|
143
|
$self->log_message($e->interpolated_message); |
52
|
2
|
|
|
|
|
116
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
JUST_LOG: |
55
|
7
|
|
|
|
|
477
|
$self->log_message($e->message, $prefix); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |