通常、ダンサーを使用する場合は、たとえば
debug 'foo';
テキストをログに記録します。しかし、ダンサーの構文をインポートしないオブジェクトにログを記録できるようにしたいと考えています。オブジェクト構文を使用してデバッグなどを呼び出すことができるように、ダンサーにログオブジェクトを渡してもらう方法があるかどうか疑問に思っています(あると思います)。
$logger->debug( 'foo' );
use Dancer::Logger::Console;
my $logger = Dancer::Logger::Console->new;
$logger->debug("Perl Dancer Rocks!");
ロガーは、 SyslogやConsoleAggregatorConsole
など、必要な他のロガーに置き換えることができます
I'm not sure I follow what you want to do, if you want a logger "that has nothing to do with Dancer" why do you want the one Dancer provides?
You can of course create an instance of a Dancer::Logger::Whatever class but then, I don't really see the point.
Why not using a real standalone logger like Log::Dispatchouli for instance?
debug キーワードのみをインポートできます。
use Dancer qw(:syntax debug);
debug 'foo';
このようにして、残りの関数が名前空間を汚染することはありませんが、おなじみの DSL 構文を引き続き使用できます。詳細については、 https://metacpan.org/module/Dancer#EXPORTSを参照してください。