--- AnyEvent/lib/AnyEvent.pm 2011/10/01 22:39:29 1.387 +++ AnyEvent/lib/AnyEvent.pm 2012/03/27 16:21:11 1.398 @@ -435,7 +435,7 @@ means in some cases, signals will be delayed. The maximum time a signal might be delayed is 10 seconds by default, but can be overriden via C<$ENV{PERL_ANYEVENT_MAX_SIGNAL_LATENCY}> or -C<$AnyEvent::MAX_SIGNAL_LATENCY> - see the Ö +C<$AnyEvent::MAX_SIGNAL_LATENCY> - see the L section for details. All these problems can be avoided by installing the optional @@ -1225,7 +1225,8 @@ # basically a tuned-down version of common::sense sub common_sense { - # from common:.sense 3.4 + # from common:.sense 3.5 + local $^W; ${^WARNING_BITS} ^= ${^WARNING_BITS} ^ "\x3c\x3f\x33\x00\x0f\xf0\x0f\xc0\xf0\xfc\x33\x00"; # use strict vars subs - NO UTF-8, as Util.pm doesn't like this atm. (uts46data.pl) $^H |= 0x00000600; @@ -1235,7 +1236,7 @@ use Carp (); -our $VERSION = '6.02'; +our $VERSION = '6.14'; our $MODEL; our @ISA; our @REGISTRY; @@ -1304,6 +1305,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 +1314,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; - - require AnyEvent::Util; - my $guard = AnyEvent::Util::guard (sub { - # "clean up" - delete $LOGGER{$logger+0}; - }); + $AnyEvent::Log::LOGGER{$logger+0} = $logger; - 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 +1398,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 +1435,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: $@"; } } } @@ -2075,28 +2076,28 @@ =item C -By default, AnyEvent will only log messages with loglevel C<3> -(C) or higher (see L). You can set this -environment variable to a numerical loglevel to make AnyEvent more (or -less) talkative. +By default, AnyEvent will log messages with loglevel C<4> (C) or +higher (see L). You can set this environment variable to a +numerical loglevel to make AnyEvent more (or less) talkative. If you want to do more than just set the global logging level you should have a look at C, which allows much more complex specifications. When set to C<0> (C), then no messages whatsoever will be logged with -the default logging settings. +everything else at defaults. -When set to C<5> or higher (C), causes AnyEvent to warn about -unexpected conditions, such as not being able to load the event model -specified by C, or a guard callback throwing an -exception - this is the minimum recommended level. +When set to C<5> or higher (C), AnyEvent warns about unexpected +conditions, such as not being able to load the event model specified by +C, or a guard callback throwing an exception - this +is the minimum recommended level for use during development. -When set to C<7> or higher (info), cause AnyEvent to report which event model it +When set to C<7> or higher (info), AnyEvent reports which event model it chooses. -When set to C<8> or higher (debug), then AnyEvent will report extra information on -which optional modules it loads and how it implements certain features. +When set to C<8> or higher (debug), then AnyEvent will report extra +information on which optional modules it loads and how it implements +certain features. =item C @@ -2113,8 +2114,8 @@ Note that specifying this environment variable causes the L module to be loaded, while C does not, so only -using the latter saves a few hundred kB of memory until the first message -is being logged. +using the latter saves a few hundred kB of memory unless a module +explicitly needs the extra features of AnyEvent::Log. =item C