ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/MP/Kernel.pm
(Generate patch)

Comparing AnyEvent-MP/MP/Kernel.pm (file contents):
Revision 1.28 by root, Sat Aug 29 16:48:18 2009 UTC vs.
Revision 1.29 by root, Sun Aug 30 09:24:09 2009 UTC

67 67
68The default simply logs the message to STDERR. 68The default simply logs the message to STDERR.
69 69
70=cut 70=cut
71 71
72our $WARNLEVEL = exists $ENV{PERL_ANYEVENT_MP_WARNLEVEL} ? $ENV{PERL_ANYEVENT_MP_WARNLEVEL} : 5;
73
72our $WARN = sub { 74our $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
89The maximum level at which warning messages will be printed to STDERR by
90the default warn handler.
91
92=cut
82 93
83sub load_func($) { 94sub load_func($) {
84 my $func = $_[0]; 95 my $func = $_[0];
85 96
86 unless (defined &$func) { 97 unless (defined &$func) {
229sub snd_on($@) { 240sub 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
236Evaluates the given string as Perl expression on the given node. 247Evaluates 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
249C<"$@"> and any results from the eval appended.
237 250
238=cut 251=cut
239 252
240sub eval_on($@) { 253sub eval_on($$;@) {
241 my $node = shift; 254 my $node = shift;
242 snd $node, eval => @_; 255 snd $node, eval => @_;
243} 256}
244 257
245sub kil(@) { 258sub kil(@) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines