line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Dispatch::Growl; |
2
|
2
|
|
|
2
|
|
60545
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
81
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.0'; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
11
|
use base qw(Log::Dispatch::Output); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1841
|
|
7
|
2
|
|
|
2
|
|
52102
|
use File::Basename qw(basename); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
206
|
|
8
|
2
|
|
|
2
|
|
11
|
use Params::Validate qw(validate SCALAR BOOLEAN); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
114
|
|
9
|
|
|
|
|
|
|
Params::Validate::validation_options( allow_extra => 1 ); |
10
|
2
|
|
|
2
|
|
1731
|
use Growl::Any; |
|
2
|
|
|
|
|
50613
|
|
|
2
|
|
|
|
|
774
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
2
|
|
|
2
|
0
|
257
|
my $param = shift; |
14
|
2
|
|
33
|
|
|
10
|
my $class = ref $param || $param; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
6
|
my $self = bless {}, $class; |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
15
|
$self->_basic_init(@_); |
19
|
2
|
|
|
|
|
218
|
$self->_init(@_); |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
5
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _init { |
25
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
113
|
my $check = { |
28
|
|
|
|
|
|
|
app_name => { |
29
|
|
|
|
|
|
|
type => SCALAR, |
30
|
|
|
|
|
|
|
default => __PACKAGE__, |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
title => { |
33
|
|
|
|
|
|
|
type => SCALAR, |
34
|
|
|
|
|
|
|
default => basename( $0 ), |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
priority => { |
37
|
|
|
|
|
|
|
type => SCALAR, |
38
|
|
|
|
|
|
|
default => 0, |
39
|
|
|
|
|
|
|
regex => qr{^\-*[0-2]$}o, |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
icon_file => { |
42
|
|
|
|
|
|
|
type => SCALAR, |
43
|
|
|
|
|
|
|
default => undef, |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
47
|
my %p = validate( @_, $check ); |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
33
|
$self->{app_name} = $p{app_name}; |
50
|
2
|
|
|
|
|
5
|
$self->{title} = $p{title}; |
51
|
2
|
|
100
|
|
|
9
|
$self->{priority} = $p{priority} || 0; |
52
|
2
|
50
|
66
|
|
|
12
|
$self->{sticky} = defined $p{sticky} && $p{sticky} ? 1 : 0; |
53
|
2
|
|
|
|
|
4
|
$self->{icon_file} = $p{icon_file}; |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
6
|
$self->{growl} = Growl::Any->new( appname => $self->{app_name}, events => [ $self->_notification_name] ); |
56
|
2
|
|
|
|
|
274
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
4
|
|
28
|
sub _notification_name { "New Message" } |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub log_message { |
62
|
2
|
|
|
2
|
0
|
667
|
my $self = shift; |
63
|
2
|
|
|
|
|
4
|
my %p = @_; |
64
|
|
|
|
|
|
|
|
65
|
2
|
|
|
|
|
7
|
$self->{growl}->notify( |
66
|
|
|
|
|
|
|
$self->_notification_name, |
67
|
|
|
|
|
|
|
$self->{title}, |
68
|
|
|
|
|
|
|
$p{message}, |
69
|
|
|
|
|
|
|
$self->{icon_file}, |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |