Skip to content

Commit

Permalink
readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
xsawyerx committed Dec 4, 2012
1 parent c5232a3 commit cbef8a7
Showing 1 changed file with 35 additions and 25 deletions.
60 changes: 35 additions & 25 deletions README.pod
Expand Up @@ -6,7 +6,7 @@ MooseX::Role::Loggable - Extensive, yet simple, logging role using Log::Dispatch

=head1 VERSION

version 0.010
version 0.100

=head1 SYNOPSIS

Expand All @@ -27,15 +27,40 @@ version 0.010
=head1 DESCRIPTION

This is a role to provide logging ability to whoever consumes it using
L<Log::Dispatchouli>. Once you consume this role, you have the attributes and
methods documented below.
L<Log::Dispatchouli>. Once you consume this role, you have attributes and
methods for logging defined automatically.

You can propagate your logging definitions to another object that uses
L<MooseX::Role::Loggable> using the C<log_fields> attribute as such:
package MyObject;
use Moose # Moo works too
with 'MooseX::Role::Loggable';

sub run {
my $self = shift;

$self->log('Trying to do something');

# this only gets written if debug flag is on
$self->log_debug('Some debugging output');

$self->log(
{ level => 'critical' },
'Critical log message',
);

$self->log_fatal('Log and die');
}

This module uses L<Moo> so it takes as little resources as it can by default,
and can seamlessly work with both L<Moo> or L<Moose>.

=head1 Propagating logging definitions

Sometimes your objects create additional object which might want to log
using the same settings. You can simply give them the same logger object.

package Parent;
use Moo; # replaces Any::Moose and Mouse (and Moose)
use MooseX::Role::Loggable; # picking Moo or Moose
use Moose;
with 'MooseX::Role::Loggable';

has child => (
is => 'ro',
Expand All @@ -46,12 +71,9 @@ L<MooseX::Role::Loggable> using the C<log_fields> attribute as such:

sub _build_child {
my $self = shift;
return Child->new( $self->log_fields );
return Child->new( logger => $self->logger );
}

This module uses L<Moo> so it takes as little resources as it can by default,
and can seamlessly work if you're using either L<Moo> or L<Moose>.

=head1 ATTRIBUTES

=head2 debug
Expand All @@ -72,7 +94,7 @@ Default: B<local6>.

The ident the logger would use. This is useful for syslog.

Default: B<MooseX::Role::Loggable>.
Default: B<calling object's class name>.

Read-only.

Expand Down Expand Up @@ -136,18 +158,6 @@ will not be logged to these>.

Default: B<stderr>

=head2 log_fields

A hash of the fields definining how logging is being done.

This is very useful when you want to propagate your logging onwards to another
object which uses L<MooseX::Role::Loggable>.

It will return the following attributes and their values in a hash: C<debug>,
C<debug>, C<logger_facility>, C<logger_ident>, C<log_to_file>,
C<log_to_stdout>, C<log_to_stderr>, C<log_file>, C<log_path>, C<log_pid>,
C<log_fail_fatal>, C<log_muted>, C<log_quiet_fatal>.

=head2 logger

A L<Log::Dispatchouli> object.
Expand Down Expand Up @@ -211,7 +221,7 @@ example:

package Stuff;

use Moo; # or Moose
use Moose;
with 'MooseX::Role::Logger';

has db => (
Expand Down

0 comments on commit cbef8a7

Please sign in to comment.