Accessing a Dancer Log Object?

Usually when using a dancer you call, for example

debug 'foo'; 

and he will record the text. But I want to be able to register material in an object that does not import dancer syntax. I am wondering if there is a way to make the dancer simply pass me this log object (I assume it is one) so that I can call things like debug using the syntax of the object, for example.

 $logger->debug( 'foo' ); 
+8
object logging perl dancer
source share
3 answers
 use Dancer::Logger::Console; my $logger = Dancer::Logger::Console->new; $logger->debug("Perl Dancer Rocks!"); 

You can replace the Console logger with any other logger you want, such as Syslog or ConsoleAggregator

+2
source share

You can import only the debug keyword.

 use Dancer qw(:syntax debug); debug 'foo'; 

This way, the rest of the functions will not pollute your namespace, but you will still have the familiar DSL syntax. See https://metacpan.org/module/Dancer#EXPORTS for more details.

0
source share

I'm not sure that I am following what you want to do if you want the registrar to have nothing to do with the dancer, why do you want one dancer to provide?

You can, of course, instantiate the Dancer :: Logger :: Whatever class, but then I really don't see the point.

Why not use a real standalone logger like Log :: Dispatchouli?

0
source share

All Articles