… | |
… | |
67 | |
67 | |
68 | The default simply logs the message to STDERR. |
68 | The default simply logs the message to STDERR. |
69 | |
69 | |
70 | =cut |
70 | =cut |
71 | |
71 | |
|
|
72 | our $WARNLEVEL = exists $ENV{PERL_ANYEVENT_MP_WARNLEVEL} ? $ENV{PERL_ANYEVENT_MP_WARNLEVEL} : 5; |
|
|
73 | |
72 | our $WARN = sub { |
74 | our $WARN = sub { |
|
|
75 | return if $WARNLEVEL < $_[0]; |
|
|
76 | |
73 | my ($level, $msg) = @_; |
77 | my ($level, $msg) = @_; |
74 | |
78 | |
75 | $msg =~ s/\n$//; |
79 | $msg =~ s/\n$//; |
76 | |
80 | |
77 | printf STDERR "%s <%d> %s\n", |
81 | printf STDERR "%s <%d> %s\n", |
78 | (POSIX::strftime "%Y-%m-%d %H:%M:%S", localtime time), |
82 | (POSIX::strftime "%Y-%m-%d %H:%M:%S", localtime time), |
79 | $level, |
83 | $level, |
80 | $msg; |
84 | $msg; |
81 | }; |
85 | }; |
|
|
86 | |
|
|
87 | =item $AnyEvent::MP::Kernel::WARNLEVEL [default 5 or $ENV{PERL_ANYEVENT_MP_WARNLEVEL}] |
|
|
88 | |
|
|
89 | The maximum level at which warning messages will be printed to STDERR by |
|
|
90 | the default warn handler. |
|
|
91 | |
|
|
92 | =cut |
82 | |
93 | |
83 | sub load_func($) { |
94 | sub load_func($) { |
84 | my $func = $_[0]; |
95 | my $func = $_[0]; |
85 | |
96 | |
86 | unless (defined &$func) { |
97 | unless (defined &$func) { |
… | |
… | |
229 | sub snd_on($@) { |
240 | sub snd_on($@) { |
230 | my $node = shift; |
241 | my $node = shift; |
231 | snd $node, snd => @_; |
242 | snd $node, snd => @_; |
232 | } |
243 | } |
233 | |
244 | |
234 | =item eval_on $node, $string |
245 | =item eval_on $node, $string[, @reply] |
235 | |
246 | |
236 | Evaluates the given string as Perl expression on the given node. |
247 | Evaluates the given string as Perl expression on the given node. When |
|
|
248 | @reply is specified, then it is used to construct a reply message with |
|
|
249 | C<"$@"> and any results from the eval appended. |
237 | |
250 | |
238 | =cut |
251 | =cut |
239 | |
252 | |
240 | sub eval_on($@) { |
253 | sub eval_on($$;@) { |
241 | my $node = shift; |
254 | my $node = shift; |
242 | snd $node, eval => @_; |
255 | snd $node, eval => @_; |
243 | } |
256 | } |
244 | |
257 | |
245 | sub kil(@) { |
258 | sub kil(@) { |