.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "MooX::Log::Any 3pm" .TH MooX::Log::Any 3pm "2016-01-20" "perl v5.22.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MooX::Log::Any \- Role to add Log::Any .SH "VERSION" .IX Header "VERSION" version 0.004004 .SH "DESCRIPTION" .IX Header "DESCRIPTION" A logging role building a very lightweight wrapper to Log::Any for use with your Moo or Moose classes. Connecting a Log::Any::Adapter should be performed prior to logging the first log message, otherwise nothing will happen, just like with Log::Any .PP Using the logger within a class is as simple as consuming a role: .PP .Vb 3 \& package MyClass; \& use Moo; \& with \*(AqMooX::Log::Any\*(Aq; \& \& sub dummy { \& my $self = shift; \& $self\->log\->info("Dummy log entry"); \& } .Ve .PP The logger needs to be setup before using the logger, which could happen in the main application: .PP .Vb 4 \& package main; \& use Log::Any::Adapter; \& # Send all logs to Log::Log4perl \& Log::Any::Adapter\->set(\*(AqLog4perl\*(Aq) \& \& use MyClass; \& my $myclass = MyClass\->new(); \& $myclass\->log\->info("In my class"); # Access the log of the object \& $myclass\->dummy; # Will log "Dummy log entry" .Ve .SH "SYNOPSIS;" .IX Header "SYNOPSIS;" .Vb 2 \& package MyApp; \& use Moo; \& \& with \*(AqMooX::Log::Any\*(Aq; \& \& sub something { \& my ($self) = @_; \& $self\->log\->debug("started bar"); ### logs with default class catergory "MyApp" \& $self\->log\->error("started bar"); ### logs with default class catergory "MyApp" \& } .Ve .SH "ACCESSORS" .IX Header "ACCESSORS" .SS "log" .IX Subsection "log" The \f(CW\*(C`log\*(C'\fR attribute holds the Log::Any::Adapter object that implements all logging methods for the defined log levels, such as \f(CW\*(C`debug\*(C'\fR or \f(CW\*(C`error\*(C'\fR. As this method is defined also in other logging roles/systems like MooseX::Log::LogDispatch this can be thought of as a common logging interface. .PP .Vb 1 \& package MyApp::View::JSON; \& \& extends \*(AqMyApp::View\*(Aq; \& with \*(AqMooseX:Log::Log4perl\*(Aq; \& \& sub bar { \& $self\->logger\->info("Everything fine so far"); # logs a info message \& $self\->logger\->debug("Something is fishy here"); # logs a debug message \& } .Ve .SS "logger([$category])" .IX Subsection "logger([$category])" This is an alias for log. .SH "SEE ALSO" .IX Header "SEE ALSO" Log::Any, Moose, Moo .SS "Inspired by" .IX Subsection "Inspired by" Inspired by the work by Chris Prather \f(CW\*(C`\*(C'\fR and Ash Berlin \f(CW\*(C`\*(C'\fR on MooseX::LogDispatch and Roland Lammel \f(CW\*(C`\*(C'\fR .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" Please report any bugs or feature requests through github . .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" In alphabetical order: .PP Jens Rehsack \f(CW\*(C`rehsack@gmail.com>\*(C'\fR .SH "AUTHOR" .IX Header "AUTHOR" Edward Ash .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2013 by Edward Ash. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.