| 1 | # $Id: /mirror/coderepos/lang/perl/MooseX-Q4MLog/trunk/lib/MooseX/Q4MLog.pm 66311 2008-07-17T01:20:46.950350Z daisuke $ | ||
| 2 | |||
| 3 | package MooseX::Q4MLog; | ||
| 4 | use Moose::Role; | ||
| 5 | use MooseX::Q4MLog::Logger; | ||
| 6 | |||
| 7 | our $VERSION = '0.00002'; | ||
| 8 | our $AUTHORITY = 'cpan:DMAKI'; | ||
| 9 | |||
| 10 | requires 'format_q4mlog'; | ||
| 11 | |||
| 12 | has 'logger' => ( | ||
| 13 | is => 'rw', | ||
| 14 | isa => 'MooseX::Q4MLog::Logger', | ||
| 15 | ); | ||
| 16 | |||
| 17 | no Moose; | ||
| 18 | |||
| 19 | sub BUILD { | ||
| 20 | my ($self, $args) = @_; | ||
| 21 | |||
| 22 | $self->logger( | ||
| 23 | MooseX::Q4MLog::Logger->new( %{ $args->{q4mlog} } ) | ||
| 24 | ); | ||
| 25 | } | ||
| 26 | |||
| 27 | sub log { | ||
| 28 | my ($self, %args) = @_; | ||
| 29 | |||
| 30 | my $q4m_args = $self->format_q4mlog(%args); | ||
| 31 | |||
| 32 | $self->logger->log( q4m_args => $q4m_args ); | ||
| 33 | } | ||
| 34 | |||
| 35 | 1; | ||
| 36 | |||
| 37 | __END__ |