From: Arthur Axel 'fREW' Schmidt Date: Fri, 22 Mar 2013 00:58:53 +0000 (-0500) Subject: Yell loudly if the user tries to use internals directly X-Git-Tag: v0.005003~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3128552037f598488679387b6e7923f2ae0633b8;p=p5sagit%2FLog-Contextual.git Yell loudly if the user tries to use internals directly --- diff --git a/Changes b/Changes index 24cb8a1..823f6ed 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ ChangeLog for Log-Contextual + - Yell loudly if a user tries to use Log::Contextual::set_logger() or + Log::Contextual::with_logger() (aka internals that don't work anymore) + directly + 0.005002 2013-02-14 (♥) - Fix RT#83267 (Tyler Riddle) diff --git a/lib/Log/Contextual.pm b/lib/Log/Contextual.pm index 2fe59eb..f0ad359 100644 --- a/lib/Log/Contextual.pm +++ b/lib/Log/Contextual.pm @@ -179,6 +179,16 @@ sub after_import { $class->router->after_import(%router_args); } +for (qw(set with)) { + no strict 'refs'; + my $sub = "${_}_logger"; + *{"Log::Contextual::$sub"} = sub { + die "$sub is no longer a direct sub in Log::Contextual. " . + 'Note that this feature was never tested nor documented. ' . + "Please fix your code to import $sub instead of trying to use it directly" + } +} + 1; __END__ diff --git a/t/yell-loudly.t b/t/yell-loudly.t new file mode 100644 index 0000000..b021186 --- /dev/null +++ b/t/yell-loudly.t @@ -0,0 +1,18 @@ +use strict; +use warnings; + +use Test::More tests => 2; +use Test::Fatal; +use Log::Contextual qw(:log); + +like( + exception { Log::Contextual::set_logger() }, + qr/set_logger is no longer a direct sub in Log::Contextual/, + 'Log::Contextual::set_logger dies', +); + +like( + exception { Log::Contextual::with_logger() }, + qr/with_logger is no longer a direct sub in Log::Contextual/, + 'Log::Contextual::with_logger dies', +);