--- AnyEvent/lib/AnyEvent.pm 2011/10/01 22:39:29 1.387 +++ AnyEvent/lib/AnyEvent.pm 2012/01/12 06:27:44 1.394 @@ -1235,7 +1235,7 @@ use Carp (); -our $VERSION = '6.02'; +our $VERSION = '6.13'; our $MODEL; our @ISA; our @REGISTRY; @@ -1304,6 +1304,7 @@ sub log($$;@) { # only load the big bloated module when we actually are about to log something if ($_[0] <= ($VERBOSE || 1)) { # also catches non-numeric levels(!) and fatal + local ($!, $@); require AnyEvent::Log; # among other things, sets $VERBOSE to 9 # AnyEvent::Log overwrites this function goto &log; @@ -1312,34 +1313,31 @@ 0 # not logged } -sub logger($;$) { - package AnyEvent::Log; - +sub _logger($;$) { my ($level, $renabled) = @_; $$renabled = $level <= $VERBOSE; - my $pkg = (caller)[0]; - - my $logger = [$pkg, $level, $renabled]; + my $logger = [(caller)[0], $level, $renabled]; - our %LOGGER; - $LOGGER{$logger+0} = $logger; + $AnyEvent::Log::LOGGER{$logger+0} = $logger; - require AnyEvent::Util; - my $guard = AnyEvent::Util::guard (sub { - # "clean up" - delete $LOGGER{$logger+0}; - }); - - sub { - return 0 unless $$renabled; - - $guard if 0; # keep guard alive, but don't cause runtime overhead - require AnyEvent::Log unless $AnyEvent::Log::VERSION; - package AnyEvent::Log; - _log ($logger->[0], $level, @_) # logger->[0] has been converted at load time - } +# return unless defined wantarray; +# +# require AnyEvent::Util; +# my $guard = AnyEvent::Util::guard (sub { +# # "clean up" +# delete $LOGGER{$logger+0}; +# }); +# +# sub { +# return 0 unless $$renabled; +# +# $guard if 0; # keep guard alive, but don't cause runtime overhead +# require AnyEvent::Log unless $AnyEvent::Log::VERSION; +# package AnyEvent::Log; +# _log ($logger->[0], $level, @_) # logger->[0] has been converted at load time +# } } if (length $ENV{PERL_ANYEVENT_LOG}) { @@ -1399,8 +1397,8 @@ # the author knows about the problems and what it does to AnyEvent as a whole # (and the ability of others to use AnyEvent), but simply wants to abuse AnyEvent # anyway. - AnyEvent::log fatal => "AnyEvent: IO::Async::Loop::AnyEvent detected - this module is broken by design,\n" - . "abuses internals and breaks AnyEvent, will not continue." + AnyEvent::log fatal => "AnyEvent: IO::Async::Loop::AnyEvent detected - that module is broken by\n" + . "design, abuses internals and breaks AnyEvent - will not continue." if exists $INC{"IO/Async/Loop/AnyEvent.pm"}; local $!; # for good measure @@ -1436,6 +1434,8 @@ AnyEvent::log 7 => "autodetected model '$model', using it."; $MODEL = $model; last; + } else { + AnyEvent::log 8 => "detected event loop $package, but cannot load '$model', skipping: $@"; } } }