« lib/POE/Component/MessageQueue/Storage/BigMemory.pm
↑ Summary
lib/POE/Component/MessageQueue/Storage/Memory.pm »
| 1 | # | ||||||||||||||||||
| 2 | # Copyright 2007-2010 David Snopek <dsnopek@gmail.com> | ||||||||||||||||||
| 3 | # | ||||||||||||||||||
| 4 | # This program is free software: you can redistribute it and/or modify | ||||||||||||||||||
| 5 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||
| 6 | # the Free Software Foundation, either version 2 of the License, or | ||||||||||||||||||
| 7 | # (at your option) any later version. | ||||||||||||||||||
| 8 | # | ||||||||||||||||||
| 9 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||
| 12 | # GNU General Public License for more details. | ||||||||||||||||||
| 13 | # | ||||||||||||||||||
| 14 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||
| 16 | # | ||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | package POE::Component::MessageQueue::Logger; | ||||||||||||||||||
| 19 | 27 | ▶ | use Moose; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 20 | 27 | ▶ | use POE::Kernel; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | 27 | my $LEVELS = { | |||||||||||||||||
| 23 | debug => 0, | ||||||||||||||||||
| 24 | info => 1, | ||||||||||||||||||
| 25 | notice => 2, | ||||||||||||||||||
| 26 | warning => 3, | ||||||||||||||||||
| 27 | error => 4, | ||||||||||||||||||
| 28 | critical => 5, | ||||||||||||||||||
| 29 | alert => 6, | ||||||||||||||||||
| 30 | emergency => 7 | ||||||||||||||||||
| 31 | }; | ||||||||||||||||||
| 32 | |||||||||||||||||||
| 33 | 27 | has 'level' => ( | |||||||||||||||||
| 34 | is => 'rw', | ||||||||||||||||||
| 35 | default => 3, | ||||||||||||||||||
| 36 | ); | ||||||||||||||||||
| 37 | |||||||||||||||||||
| 38 | 27 | has 'logger_alias' => ( | |||||||||||||||||
| 39 | is => 'rw', | ||||||||||||||||||
| 40 | writer => 'set_logger_alias', | ||||||||||||||||||
| 41 | predicate => 'has_logger_alias', | ||||||||||||||||||
| 42 | ); | ||||||||||||||||||
| 43 | |||||||||||||||||||
| 44 | 27 | has 'log_function' => ( | |||||||||||||||||
| 45 | is => 'rw', | ||||||||||||||||||
| 46 | writer => 'set_log_function', | ||||||||||||||||||
| 47 | predicate => 'has_log_function', | ||||||||||||||||||
| 48 | ); | ||||||||||||||||||
| 49 | |||||||||||||||||||
| 50 | sub log | ||||||||||||||||||
| 51 | { | ||||||||||||||||||
| 52 | 8666 | ▶ | my ($self, $type, $msg) = @_; | ||||||||||||||||
|
Subroutine
log: called CC=5 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | 8666 | ▶ | if ( not defined $msg ) | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 55 | { | ||||||||||||||||||
| 56 | 0 | $msg = $type; | |||||||||||||||||
| 57 | 0 | $type = 'info'; | |||||||||||||||||
| 58 | } | ||||||||||||||||||
| 59 | |||||||||||||||||||
| 60 | 8666 | ▶ | if ( $self->has_log_function ) | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 61 | { | ||||||||||||||||||
| 62 | 162 | $self->log_function->( $type, $msg ); | |||||||||||||||||
| 63 | } | ||||||||||||||||||
| 64 | elsif ( $self->has_logger_alias ) | ||||||||||||||||||
| 65 | { | ||||||||||||||||||
| 66 | 0 | $poe_kernel->post($self->logger_alias, $type, "$msg\n" ); | |||||||||||||||||
| 67 | } | ||||||||||||||||||
| 68 | elsif ($LEVELS->{$type} >= $self->level ) | ||||||||||||||||||
| 69 | { | ||||||||||||||||||
| 70 | 0 | print STDERR "$msg\n"; | |||||||||||||||||
| 71 | } | ||||||||||||||||||
| 72 | } | ||||||||||||||||||
| 73 | |||||||||||||||||||
| 74 | sub shutdown | ||||||||||||||||||
| 75 | { | ||||||||||||||||||
| 76 | 4 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
shutdown: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||
| 77 | |||||||||||||||||||
| 78 | 4 | ▶ | if ($self->has_logger_alias) | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 79 | { | ||||||||||||||||||
| 80 | 0 | $poe_kernel->signal( $self->logger_alias, 'TERM' ); | |||||||||||||||||
| 81 | } | ||||||||||||||||||
| 82 | } | ||||||||||||||||||
| 83 | |||||||||||||||||||
| 84 | 27 | 1; | |||||||||||||||||
| 85 | |||||||||||||||||||