ChangeLog for Log-Contextual
+ - Fix RT#83267 (Tyler Riddle)
+
0.005001 2013-02-07
- No changes from previous dev release
use Data::Dumper::Concise;
use Scalar::Util 'blessed';
+my @dlog = ((map "Dlog_$_", @levels), (map "DlogS_$_", @levels));
+
+my @log = ((map "log_$_", @levels), (map "logS_$_", @levels));
+
eval {
require Log::Log4perl;
die if $Log::Log4perl::VERSION < 1.29;
# export anything but the levels selected
sub ____ { }
-exports(qw(____ set_logger with_logger ));
+exports ('____',
+ @dlog, @log,
+ qw( set_logger with_logger )
+);
export_tag dlog => ('____');
export_tag log => ('____');
my @levels = @{$class->arg_levels($spec->config->{levels})};
for my $level (@levels) {
- if ($spec->config->{log}) {
+ if ($spec->config->{log} || $exports->{"&log_$level"}) {
$spec->add_export(
"&log_$level",
sub (&@) {
);
return @args;
});
+ }
+ if ($spec->config->{log} || $exports->{"&logS_$level"}) {
$spec->add_export(
"&logS_$level",
sub (&@) {
return $args[0];
});
}
- if ($spec->config->{dlog}) {
+ if ($spec->config->{dlog} || $exports->{"&Dlog_$level"}) {
$spec->add_export(
"&Dlog_$level",
sub (&@) {
);
return @args;
});
+ }
+ if ($spec->config->{dlog} || $exports->{"&DlogS_$level"}) {
$spec->add_export(
"&DlogS_$level",
sub (&$) {
--- /dev/null
+use Test::More qw(no_plan);
+
+BEGIN {
+ eval {
+ package NotMain;
+
+ use strict;
+ use warnings;
+ use Test::More;
+ use Log::Contextual::SimpleLogger;
+
+ use Log::Contextual qw(:log),
+ -default_logger =>
+ Log::Contextual::SimpleLogger->new({levels => [qw( )]});
+
+ eval {
+ log_info { "Yep" }
+ };
+ is($@, '', 'Invoked log function in package other than main');
+ };
+
+ is($@, '', 'non-main package subtest did not die');
+}
--- /dev/null
+use strict;
+use warnings;
+use Test::More 'no_plan';
+
+#bug report does not include a case where Log::Contextual is
+#brought in via 'use'
+
+#try to import a single log function but do not include any tags
+BEGIN {
+ require Log::Contextual;
+ Log::Contextual->import('log_info');
+}
+
+eval {
+ log_info { "test" };
+};
+like(
+ $@,
+ qr/^ no logger set! you can't try to log something without a logger!/,
+ 'Got correct error'
+);