| 1 | package Jifty::Plugin::TestServerWarnings::Appender; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use base qw/Log::Log4perl::Appender/; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Jifty::Plugin::TestServerWarnings::Appender - Log appender | ||
| 9 | |||
| 10 | =head1 DESCRIPTION | ||
| 11 | |||
| 12 | L<Log::Log4perl::Appender> which stores warnings in memory, for later | ||
| 13 | downloading by the test client. | ||
| 14 | |||
| 15 | =head1 METHODS | ||
| 16 | |||
| 17 | =head2 new | ||
| 18 | |||
| 19 | Creates a new appender; takes no arguments. | ||
| 20 | |||
| 21 | =cut | ||
| 22 | |||
| 23 | sub new { | ||
| 24 | my $class = shift; | ||
| 25 | return bless {@_}, $class; | ||
| 26 | } | ||
| 27 | |||
| 28 | =head2 log | ||
| 29 | |||
| 30 | Appends the message to L<Jifty::Plugin::TestServerWarnings>' internal | ||
| 31 | storage. | ||
| 32 | |||
| 33 | =cut | ||
| 34 | |||
| 35 | sub log { | ||
| 36 | my $self = shift; | ||
| 37 | my $plugin = Jifty->find_plugin("Jifty::Plugin::TestServerWarnings"); | ||
| 38 | my $message = $_[0]{message}; | ||
| 39 | $message = join('',@{$message}) if ref $message eq "ARRAY"; | ||
| 40 | $plugin->add_warnings($message); | ||
| 41 | } | ||
| 42 | |||
| 43 | 1; |