--- AnyEvent/lib/AnyEvent/Log.pm 2011/08/25 00:08:10 1.28 +++ AnyEvent/lib/AnyEvent/Log.pm 2011/08/25 03:08:48 1.31 @@ -251,7 +251,7 @@ $format = $format->() if ref $format; $format = sprintf $format, @args if @args; $format =~ s/\n$//; - $now = AE::now; + $now = now; }; # format msg @@ -1089,20 +1089,44 @@ =back +Any character can be escaped by prefixing it with a C<\> (backslash), as +usual, so to log to a file containing a comma, colon, backslash and space in the +filename, you would do this: + + PERL_ANYEVENT_LOG='log=file=/some\ \:file\ with\,\ \\-escapes' + +Since whitespace (which includes newlines) is allowed, it is fine to +specify multiple lines in C, e.g.: + + PERL_ANYEVENT_LOG=" + filter=warn + AnyEvent::Debug=+%trace + %trace=only,trace,+log + " myprog + +Also, in the unlikely case when you want to concatenate specifications, +use whitespace as separator, as C<::> will be interpreted as part of a +module name, an empty spec with two separators: + + PERL_ANYEVENT_LOG="$PERL_ANYEVENT_LOG MyMod=debug" + =cut for (my $spec = $ENV{PERL_ANYEVENT_LOG}) { my %anon; my $pkg = sub { - $_[0] eq "log" ? $LOG - : $_[0] eq "filter" ? $FILTER - : $_[0] eq "collect" ? $COLLECT - : $_[0] =~ /^%(.+)$/ && $anon{$1} ||= ctx undef - : $_[0] =~ /^(.*?)(?:::)?$/ && ctx "$1" # egad :/ + $_[0] eq "log" ? $LOG + : $_[0] eq "filter" ? $FILTER + : $_[0] eq "collect" ? $COLLECT + : $_[0] =~ /^%(.+)$/ ? ($anon{$1} ||= ctx undef) + : $_[0] =~ /^(.*?)(?:::)?$/ ? ctx "$1" # egad :/ + : die # never reached? }; - while (/\G((?:[^:=]+|::|\\.)+)=/gc) { + /\G[[:space:]]+/gc; # skip initial whitespace + + while (/\G((?:[^:=[:space:]]+|::|\\.)+)=/gc) { my $ctx = $pkg->($1); my $level = "level"; @@ -1129,9 +1153,11 @@ /\G,/gc or last; } - /\G[:[:space:]]/gc or last; + /\G[:[:space:]]+/gc or last; } + /\G[[:space:]]+/gc; # skip trailing whitespace + if (/\G(.+)/g) { die "PERL_ANYEVENT_LOG ($spec): parse error at '$1'\n"; }