| 1 | package POE::Component::Server::Twirc::LogAppender; | ||||||||||
| 2 | 2 | $POE::Component::Server::Twirc::LogAppender::VERSION = '0.20'; | |||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use base qw/Log::Log4perl::Appender/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 9 | 0 | my($class, @options) = @_; | |||||||||
| 10 | |||||||||||
| 11 | 0 | my $self = { | |||||||||
| 12 | name => 'twirc-logger', | ||||||||||
| 13 | irc_channel => '&twirc-log', | ||||||||||
| 14 | history => [], | ||||||||||
| 15 | history_size => 50, | ||||||||||
| 16 | @options, | ||||||||||
| 17 | }; | ||||||||||
| 18 | |||||||||||
| 19 | 0 | for ( qw/ircd irc_botname irc_channel/ ) { | |||||||||
| 20 | 0 | ▶ | die "$_ required" unless defined $self->{$_}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 0 | bless $self, $class; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub log { | ||||||||
|
Subroutine
log: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 27 | 0 | my($self, %params) = @_; | |||||||||
| 28 | |||||||||||
| 29 | $self->{ircd}->yield(daemon_cmd_privmsg => | ||||||||||
| 30 | 0 | $self->{irc_botname}, $self->{irc_channel}, $params{message}); | |||||||||
| 31 | |||||||||||
| 32 | 0 | push @{$self->{history}}, \%params; | |||||||||
| 33 | 0 | ▶ | shift @{$self->{history}} while @{$self->{history}} > $self->{history_size}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | sub dump_history { | ||||||||
|
Subroutine
dump_history: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 37 | 0 | my $self = shift; | |||||||||
| 38 | |||||||||||
| 39 | $self->{ircd}->yield(daemon_cmd_privmsg => | ||||||||||
| 40 | $self->{irc_botname}, $self->{irc_channel}, $_->{message}) | ||||||||||
| 41 | 0 | for @{$self->{history}}; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 2 | 1; | |||||||||