| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Log::Dispatch::Twitter; |
|
2
|
2
|
|
|
2
|
|
49098
|
use strict; |
|
|
2
|
|
|
|
|
14
|
|
|
|
2
|
|
|
|
|
83
|
|
|
3
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
77
|
|
|
4
|
2
|
|
|
2
|
|
52
|
use 5.008001; |
|
|
2
|
|
|
|
|
14
|
|
|
|
2
|
|
|
|
|
97
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use base 'Log::Dispatch::Output'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
2088
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 0.03; |
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
34986
|
use Net::Twitter; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
|
|
|
|
|
|
my $class = shift; |
|
13
|
|
|
|
|
|
|
my $self = bless {}, $class; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$self->_basic_init(@_); |
|
16
|
|
|
|
|
|
|
$self->_init(@_); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
return $self; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _init { |
|
22
|
|
|
|
|
|
|
my $self = shift; |
|
23
|
|
|
|
|
|
|
my %args = @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Remove Log::Dispatch::Output constructor args |
|
26
|
|
|
|
|
|
|
delete @args{qw{ |
|
27
|
|
|
|
|
|
|
name |
|
28
|
|
|
|
|
|
|
min_level |
|
29
|
|
|
|
|
|
|
max_level |
|
30
|
|
|
|
|
|
|
callbacks |
|
31
|
|
|
|
|
|
|
newline |
|
32
|
|
|
|
|
|
|
}}; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$self->{args} = \%args; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub log_message { |
|
38
|
|
|
|
|
|
|
my $self = shift; |
|
39
|
|
|
|
|
|
|
my %args = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $message = $args{message}; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# we could truncate here, but better to let Net::Twitter, or even Twitter |
|
44
|
|
|
|
|
|
|
# itself, do it. we don't want to have to release a new version to support |
|
45
|
|
|
|
|
|
|
# 145 character log messages. :) |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$self->_post_message($message); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _post_message { |
|
51
|
|
|
|
|
|
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
my $message = shift; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $twitter = Net::Twitter->new(%{ $self->{args} }); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$twitter->update($message); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Log::Dispatch::Twitter - Log messages via Twitter |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use Log::Dispatch; |
|
70
|
|
|
|
|
|
|
use Log::Dispatch::Twitter; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $logger = Log::Dispatch->new; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$logger->add(Log::Dispatch::Twitter->new( |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
username => "foo", |
|
77
|
|
|
|
|
|
|
password => "bar", |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Net::Twitter args |
|
80
|
|
|
|
|
|
|
traits => [qw/OAuth API::REST/], |
|
81
|
|
|
|
|
|
|
consumer_key => $consumer_key, |
|
82
|
|
|
|
|
|
|
consumer_secret => $consumer_secret, |
|
83
|
|
|
|
|
|
|
access_token => $token, |
|
84
|
|
|
|
|
|
|
access_token_secret => $token_secret, |
|
85
|
|
|
|
|
|
|
)); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$logger->log( |
|
88
|
|
|
|
|
|
|
level => 'error', |
|
89
|
|
|
|
|
|
|
message => 'We applied the cortical electrodes but were unable to get a neural reaction from either patient.', |
|
90
|
|
|
|
|
|
|
); |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Twitter is a presence tracking site. Why not track your program's presence? |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Shawn M Moore, C<sartak@gmail.com> |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright 2008-2010 Shawn M Moore. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
105
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
|
108
|
|
|
|
|
|
|
|