… | |
… | |
1058 | If L<AnyEvent::Log> is not loaded then this function makes a simple test |
1058 | If L<AnyEvent::Log> is not loaded then this function makes a simple test |
1059 | to see whether the message will be logged. If the test succeeds it will |
1059 | to see whether the message will be logged. If the test succeeds it will |
1060 | load AnyEvent::Log and call C<AnyEvent::Log::log> - consequently, look at |
1060 | load AnyEvent::Log and call C<AnyEvent::Log::log> - consequently, look at |
1061 | the L<AnyEvent::Log> documentation for details. |
1061 | the L<AnyEvent::Log> documentation for details. |
1062 | |
1062 | |
1063 | If the test fails it will simply return. |
1063 | If the test fails it will simply return. Right now this happens when a |
|
|
1064 | numerical loglevel is used and it is larger than the level specified via |
|
|
1065 | C<$ENV{PERL_ANYEVENT_VERBOSE}>. |
1064 | |
1066 | |
1065 | If you want to sprinkle loads of logging calls around your code, consider |
1067 | If you want to sprinkle loads of logging calls around your code, consider |
1066 | creating a logger callback with the C<AnyEvent::Log::logger> function, |
1068 | creating a logger callback with the C<AnyEvent::Log::logger> function, |
1067 | which can reduce typing, codesize and can reduce the logging overhead |
1069 | which can reduce typing, codesize and can reduce the logging overhead |
1068 | enourmously. |
1070 | enourmously. |
… | |
… | |
1235 | |
1237 | |
1236 | use Carp (); |
1238 | use Carp (); |
1237 | |
1239 | |
1238 | our $VERSION = '6.02'; |
1240 | our $VERSION = '6.02'; |
1239 | our $MODEL; |
1241 | our $MODEL; |
1240 | |
|
|
1241 | our @ISA; |
1242 | our @ISA; |
1242 | |
|
|
1243 | our @REGISTRY; |
1243 | our @REGISTRY; |
1244 | |
|
|
1245 | our $VERBOSE; |
1244 | our $VERBOSE; |
|
|
1245 | our $MAX_SIGNAL_LATENCY = 10; |
|
|
1246 | our %PROTOCOL; # (ipv4|ipv6) => (1|2), higher numbers are preferred |
1246 | |
1247 | |
1247 | BEGIN { |
1248 | BEGIN { |
1248 | require "AnyEvent/constants.pl"; |
1249 | require "AnyEvent/constants.pl"; |
1249 | |
1250 | |
1250 | eval "sub TAINT (){" . (${^TAINT}*1) . "}"; |
1251 | eval "sub TAINT (){" . (${^TAINT}*1) . "}"; |
… | |
… | |
1256 | for grep s/^AE_// && !exists $ENV{"PERL_ANYEVENT_$_"}, keys %ENV; |
1257 | for grep s/^AE_// && !exists $ENV{"PERL_ANYEVENT_$_"}, keys %ENV; |
1257 | |
1258 | |
1258 | @ENV{grep /^PERL_ANYEVENT_/, keys %ENV} = () |
1259 | @ENV{grep /^PERL_ANYEVENT_/, keys %ENV} = () |
1259 | if ${^TAINT}; |
1260 | if ${^TAINT}; |
1260 | |
1261 | |
1261 | $VERBOSE = $ENV{PERL_ANYEVENT_VERBOSE}*1; |
1262 | # $ENV{PERL_ANYEVENT_xxx} now valid |
1262 | } |
|
|
1263 | |
1263 | |
1264 | our $MAX_SIGNAL_LATENCY = 10; |
1264 | $VERBOSE = length $ENV{PERL_ANYEVENT_VERBOSE} ? $ENV{PERL_ANYEVENT_VERBOSE}*1 : 3; |
1265 | |
1265 | |
1266 | our %PROTOCOL; # (ipv4|ipv6) => (1|2), higher numbers are preferred |
|
|
1267 | |
|
|
1268 | { |
|
|
1269 | my $idx; |
1266 | my $idx; |
1270 | $PROTOCOL{$_} = ++$idx |
1267 | $PROTOCOL{$_} = ++$idx |
1271 | for reverse split /\s*,\s*/, |
1268 | for reverse split /\s*,\s*/, |
1272 | $ENV{PERL_ANYEVENT_PROTOCOLS} || "ipv4,ipv6"; |
1269 | $ENV{PERL_ANYEVENT_PROTOCOLS} || "ipv4,ipv6"; |
1273 | } |
1270 | } |
… | |
… | |
2040 | |
2037 | |
2041 | =over 4 |
2038 | =over 4 |
2042 | |
2039 | |
2043 | =item C<PERL_ANYEVENT_VERBOSE> |
2040 | =item C<PERL_ANYEVENT_VERBOSE> |
2044 | |
2041 | |
2045 | By default, AnyEvent will be completely silent except in fatal |
2042 | By default, AnyEvent will only log messages with loglevel C<3> |
2046 | conditions. You can set this environment variable to make AnyEvent more |
2043 | (C<critical>) or higher (see L<AnyEvent::Log>). You can set this |
|
|
2044 | environment variable to a numerical loglevel to make AnyEvent more (or |
|
|
2045 | less) talkative. |
|
|
2046 | |
2047 | talkative. If you want to do more than just set the global logging level |
2047 | If you want to do more than just set the global logging level |
2048 | you should have a look at C<PERL_ANYEVENT_LOG>, which allows much more |
2048 | you should have a look at C<PERL_ANYEVENT_LOG>, which allows much more |
2049 | complex specifications. |
2049 | complex specifications. |
2050 | |
2050 | |
|
|
2051 | When set to C<0> (C<off>), then no messages whatsoever will be logged with |
|
|
2052 | the default logging settings. |
|
|
2053 | |
2051 | When set to C<5> or higher (warn), causes AnyEvent to warn about unexpected |
2054 | When set to C<5> or higher (C<warn>), causes AnyEvent to warn about |
2052 | conditions, such as not being able to load the event model specified by |
2055 | unexpected conditions, such as not being able to load the event model |
2053 | C<PERL_ANYEVENT_MODEL>, or a guard callback throwing an exception - this |
2056 | specified by C<PERL_ANYEVENT_MODEL>, or a guard callback throwing an |
2054 | is the minimum recommended level. |
2057 | exception - this is the minimum recommended level. |
2055 | |
2058 | |
2056 | When set to C<7> or higher (info), cause AnyEvent to report which event model it |
2059 | When set to C<7> or higher (info), cause AnyEvent to report which event model it |
2057 | chooses. |
2060 | chooses. |
2058 | |
2061 | |
2059 | When set to C<8> or higher (debug), then AnyEvent will report extra information on |
2062 | When set to C<8> or higher (debug), then AnyEvent will report extra information on |
… | |
… | |
2092 | C<PERL_ANYEVENT_STRICT=1> in your environment while developing programs |
2095 | C<PERL_ANYEVENT_STRICT=1> in your environment while developing programs |
2093 | can be very useful, however. |
2096 | can be very useful, however. |
2094 | |
2097 | |
2095 | =item C<PERL_ANYEVENT_DEBUG_SHELL> |
2098 | =item C<PERL_ANYEVENT_DEBUG_SHELL> |
2096 | |
2099 | |
2097 | If this env variable is set, then its contents will be interpreted by |
2100 | If this env variable is nonempty, then its contents will be interpreted by |
2098 | C<AnyEvent::Socket::parse_hostport> (after replacing every occurance of |
2101 | C<AnyEvent::Socket::parse_hostport> and C<AnyEvent::Debug::shell> (after |
2099 | C<$$> by the process pid) and an C<AnyEvent::Debug::shell> is bound on |
2102 | replacing every occurance of C<$$> by the process pid). The shell object |
2100 | that port. The shell object is saved in C<$AnyEvent::Debug::SHELL>. |
2103 | is saved in C<$AnyEvent::Debug::SHELL>. |
2101 | |
2104 | |
2102 | This happens when the first watcher is created. |
2105 | This happens when the first watcher is created. |
2103 | |
2106 | |
2104 | For example, to bind a debug shell on a unix domain socket in |
2107 | For example, to bind a debug shell on a unix domain socket in |
2105 | F<< /tmp/debug<pid>.sock >>, you could use this: |
2108 | F<< /tmp/debug<pid>.sock >>, you could use this: |
2106 | |
2109 | |
2107 | PERL_ANYEVENT_DEBUG_SHELL=/tmp/debug\$\$.sock perlprog |
2110 | PERL_ANYEVENT_DEBUG_SHELL=/tmp/debug\$\$.sock perlprog |
|
|
2111 | # connect with e.g.: socat readline /tmp/debug123.sock |
2108 | |
2112 | |
|
|
2113 | Or to bind to tcp port 4545 on localhost: |
|
|
2114 | |
|
|
2115 | PERL_ANYEVENT_DEBUG_SHELL=127.0.0.1:4545 perlprog |
|
|
2116 | # connect with e.g.: telnet localhost 4545 |
|
|
2117 | |
2109 | Note that creating sockets in F</tmp> is very unsafe on multiuser |
2118 | Note that creating sockets in F</tmp> or on localhost is very unsafe on |
2110 | systems. |
2119 | multiuser systems. |
2111 | |
2120 | |
2112 | =item C<PERL_ANYEVENT_DEBUG_WRAP> |
2121 | =item C<PERL_ANYEVENT_DEBUG_WRAP> |
2113 | |
2122 | |
2114 | Can be set to C<0>, C<1> or C<2> and enables wrapping of all watchers for |
2123 | Can be set to C<0>, C<1> or C<2> and enables wrapping of all watchers for |
2115 | debugging purposes. See C<AnyEvent::Debug::wrap> for details. |
2124 | debugging purposes. See C<AnyEvent::Debug::wrap> for details. |