line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
308557
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
93
|
|
2
|
4
|
|
|
4
|
|
13
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
171
|
|
3
|
|
|
|
|
|
|
# Copyright (C) 2017 Christian Garbs <mitch@cgarbs.de> |
4
|
|
|
|
|
|
|
# Licensed under GNU GPL v2 or later. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Log::Dispatch::Desktop::Notify; |
7
|
|
|
|
|
|
|
$Log::Dispatch::Desktop::Notify::VERSION = 'v0.0.1'; |
8
|
|
|
|
|
|
|
# ABSTRACT: Log::Dispatch notification backend using Desktop::Notify |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
429
|
use Desktop::Notify; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
63
|
|
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
1068
|
use parent 'Log::Dispatch::Output'; |
|
3
|
|
|
|
|
645
|
|
|
3
|
|
|
|
|
11
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
8
|
|
|
8
|
1
|
12105
|
my ($class, %params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
8
|
|
|
|
|
26
|
my $self = bless { |
19
|
|
|
|
|
|
|
_timeout => -1, |
20
|
|
|
|
|
|
|
_app_name => $0, |
21
|
|
|
|
|
|
|
}, $class; |
22
|
|
|
|
|
|
|
|
23
|
8
|
|
|
|
|
45
|
$self->_basic_init(%params); |
24
|
8
|
|
|
|
|
573
|
$self->_init(%params); |
25
|
|
|
|
|
|
|
|
26
|
8
|
|
|
|
|
85
|
return $self; |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _init { |
30
|
8
|
|
|
8
|
|
13
|
my ($self, %params) = @_; |
31
|
|
|
|
|
|
|
|
32
|
8
|
100
|
|
|
|
23
|
$self->{_app_name} = $params{app_name} if defined $params{app_name}; |
33
|
8
|
100
|
|
|
|
19
|
$self->{_timeout} = $params{timeout} if defined $params{timeout}; |
34
|
|
|
|
|
|
|
|
35
|
8
|
|
|
|
|
34
|
$self->{_notify} = Desktop::Notify->new( app_name => $self->{_app_name} ); |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub log_message { |
40
|
5
|
|
|
5
|
1
|
264
|
my ($self, %params) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $notification = $self->{_notify}->create( |
43
|
|
|
|
|
|
|
summary => $params{message}, |
44
|
|
|
|
|
|
|
timeout => $self->{_timeout}, |
45
|
5
|
|
|
|
|
25
|
); |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
71
|
$notification->show(); |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=encoding UTF-8 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Log::Dispatch::Desktop::Notify - Log::Dispatch notification backend using Desktop::Notify |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 VERSION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
version v0.0.1 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SYNOPSIS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use Log::Dispatch; |
70
|
|
|
|
|
|
|
use Log::Dispatch::Desktop::Notify; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $log = Log::Dispatch->new(); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$log->add( Log::Dispatch::Desktop::Notify->new( |
75
|
|
|
|
|
|
|
min_level => 'warning' |
76
|
|
|
|
|
|
|
)); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$log->log( level => 'warning', message => 'a problem!' ); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Log::Dispatch::Desktop::Notify is a backend for L<Log::Dispatch> that |
83
|
|
|
|
|
|
|
displays messages via the Desktop Notification Framework (think |
84
|
|
|
|
|
|
|
C<libnotify>) using L<Desktop::Notify>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 METHODS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 new |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Creates a new L<Log::Dispatch::Desktop::Notify> object. Expects named |
91
|
|
|
|
|
|
|
parameters as a hash. In addition to the usual parameters of |
92
|
|
|
|
|
|
|
L<Log::Dispatch::Output> these parameters are also supported: |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item timeout |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Default value: C<-1> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Sets the message timeout in milliseconds. C<0> disables the timeout, |
101
|
|
|
|
|
|
|
the message has to be closed manually. C<-1> uses the default timeout |
102
|
|
|
|
|
|
|
of the notification server. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item app_name |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Default value: C<$0> (script name) |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Sets the application name for the message display. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=back |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 log_message |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This message is called internally by C<Log::Dispatch::log()> to |
115
|
|
|
|
|
|
|
display a message. Expects named parameters in a hash. Currently, |
116
|
|
|
|
|
|
|
only the usual L<Log::Dispatch::Output> parameters C<level> and |
117
|
|
|
|
|
|
|
C<message> are supported. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
To report a bug, please use the github issue tracker: |
122
|
|
|
|
|
|
|
L<https://github.com/mmitch/log-dispatch-desktop-notify/issues> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AVAILABILITY |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item github repository |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L<git://github.com/mmitch/log-dispatch-desktop-notify.git> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item github browser |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L<https://github.com/mmitch/log-dispatch-desktop-notify> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item github issue tracker |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L<https://github.com/mmitch/log-dispatch-desktop-notify/issues> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=begin html |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 BUILD STATUS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
<p><a href="https://travis-ci.org/mmitch/log-dispatch-desktop-notify"><img src="https://travis-ci.org/mmitch/log-dispatch-desktop-notify.svg?branch=master" alt="Build Status"></a></p> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=end html |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=begin html |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 TEST COVERAGE |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
<p><a href="https://codecov.io/github/mmitch/log-dispatch-desktop-notify?branch=master"><img src="https://codecov.io/github/mmitch/log-dispatch-desktop-notify/coverage.svg?branch=master" alt="Coverage Status"></a></p> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=end html |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 SEE ALSO |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=over |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
L<Log::Dispatch> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item * |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
L<Desktop::Notify> |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=back |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 AUTHOR |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Christian Garbs <mitch@cgarbs.de> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Copyright (C) 2017 Christian Garbs |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it |
183
|
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the Free |
184
|
|
|
|
|
|
|
Software Foundation, either version 2 of the License, or (at your option) |
185
|
|
|
|
|
|
|
any later version. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT |
188
|
|
|
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
189
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
190
|
|
|
|
|
|
|
more details. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along |
193
|
|
|
|
|
|
|
with this program. If not, see <http://www.gnu.org/licenses/>. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |