package MooseX::JobControl::Logger;
use Moose;
use MooseX::LogDispatch;
with qw( MooseX::JobControl::Interface::Observer);
with Logger( interface => 'Levels' );

my @LEVEL = qw(
  debug
  info
  notice
  warning
  error
  critical
  alert
  emergency
);

sub worker_stdout {
    my ( $self, $msg, $id, $pid ) = @_;
    $pid ||= $id;
    $self->info("[$pid]: $msg");
}

sub worker_error {
    my ( $self, $operation, $errnum, $errstr, $id, $pid ) = @_;
    my $level = $LEVEL[$errnum];
    $self->$level("[$pid] $operation $errstr");
}

sub notify {
    (shift)->debug( join ' ', @_ );
}

no Moose;
1;
__END__
