Hi, you missed one very important part of the doc for Log::Any::Adapter::File:
"Category is ignored."
Also, note that the consumers of your log statements decide what they will consume by setting the log level, as well as the category (assuming the adapter they choose to use supports filtering by log level). So specifying a log level when defining the logger attribute of your object will have no effect: all you can control as the producer is the level of the message. Here's a simple demonstration:
Module:
Script:package MyClass; use Log::Any (); use Moo; has log => ( is => 'ro', default => sub { Log::Any->get_logger(category => 'unfolder') }, ); sub greet { $_[0]->log->debug('HELO, WORLD'); }; 1; __END__
Tests:# 1224985.pl use strict; use warnings; use feature 'say'; use lib '.'; use MyClass; use Log::Any::Adapter; my $level = shift or die 'log level must be provided'; my $obj = MyClass->new; Log::Any::Adapter->set('Stdout', log_level => $level); say '>'; $obj->greet; say '<'; __END__
$ perl 1224985.pl critical > < $ perl 1224985.pl debug > HELO, WORLD <
Hope this helps!
In reply to Re: Turning off logging
by 1nickt
in thread Turning off logging
by frazap
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |