… | |
… | |
967 | filter=debug:log=+%warnings:%warnings=warn,syslog=LOG_LOCAL0 |
967 | filter=debug:log=+%warnings:%warnings=warn,syslog=LOG_LOCAL0 |
968 | |
968 | |
969 | # log trace messages (only) from AnyEvent::Debug to file |
969 | # log trace messages (only) from AnyEvent::Debug to file |
970 | AnyEvent::Debug=+%trace:%trace=only,trace,file=/tmp/tracelog |
970 | AnyEvent::Debug=+%trace:%trace=only,trace,file=/tmp/tracelog |
971 | |
971 | |
|
|
972 | Since whitespace (which includes newlines) is allowed, it is fine to |
|
|
973 | specify multiple lines in C<PERL_ANYEVENT_LOG>, e.g.: |
|
|
974 | |
|
|
975 | PERL_ANYEVENT_LOG=" |
|
|
976 | filter=warn |
|
|
977 | AnyEvent::Debug=+%trace |
|
|
978 | %trace=only,trace,+log |
|
|
979 | " myprog |
|
|
980 | |
972 | A context name in the log specification can be any of the following: |
981 | A context name in the log specification can be any of the following: |
973 | |
982 | |
974 | =over 4 |
983 | =over 4 |
975 | |
984 | |
976 | =item C<collect>, C<filter>, C<log> |
985 | =item C<collect>, C<filter>, C<log> |
… | |
… | |
1093 | |
1102 | |
1094 | for (my $spec = $ENV{PERL_ANYEVENT_LOG}) { |
1103 | for (my $spec = $ENV{PERL_ANYEVENT_LOG}) { |
1095 | my %anon; |
1104 | my %anon; |
1096 | |
1105 | |
1097 | my $pkg = sub { |
1106 | my $pkg = sub { |
1098 | $_[0] eq "log" ? $LOG |
1107 | $_[0] eq "log" ? $LOG |
1099 | : $_[0] eq "filter" ? $FILTER |
1108 | : $_[0] eq "filter" ? $FILTER |
1100 | : $_[0] eq "collect" ? $COLLECT |
1109 | : $_[0] eq "collect" ? $COLLECT |
1101 | : $_[0] =~ /^%(.+)$/ && $anon{$1} ||= ctx undef |
1110 | : $_[0] =~ /^%(.+)$/ ? ($anon{$1} ||= ctx undef) |
1102 | : $_[0] =~ /^(.*?)(?:::)?$/ && ctx "$1" # egad :/ |
1111 | : $_[0] =~ /^(.*?)(?:::)?$/ ? ctx "$1" # egad :/ |
|
|
1112 | : die # never reached? |
1103 | }; |
1113 | }; |
1104 | |
1114 | |
|
|
1115 | /\G[[:space:]]+/gc; # skip initial whitespace |
|
|
1116 | |
1105 | while (/\G((?:[^:=]+|::|\\.)+)=/gc) { |
1117 | while (/\G((?:[^:=[:space:]]+|::|\\.)+)=/gc) { |
1106 | my $ctx = $pkg->($1); |
1118 | my $ctx = $pkg->($1); |
1107 | my $level = "level"; |
1119 | my $level = "level"; |
1108 | |
1120 | |
1109 | while (/\G((?:[^,:[:space:]]+|::|\\.)+)/gc) { |
1121 | while (/\G((?:[^,:[:space:]]+|::|\\.)+)/gc) { |
1110 | for ("$1") { |
1122 | for ("$1") { |
… | |
… | |
1127 | } |
1139 | } |
1128 | |
1140 | |
1129 | /\G,/gc or last; |
1141 | /\G,/gc or last; |
1130 | } |
1142 | } |
1131 | |
1143 | |
1132 | /\G[:[:space:]]/gc or last; |
1144 | /\G[:[:space:]]+/gc or last; |
1133 | } |
1145 | } |
|
|
1146 | |
|
|
1147 | /\G[[:space:]]+/gc; # skip trailing whitespace |
1134 | |
1148 | |
1135 | if (/\G(.+)/g) { |
1149 | if (/\G(.+)/g) { |
1136 | die "PERL_ANYEVENT_LOG ($spec): parse error at '$1'\n"; |
1150 | die "PERL_ANYEVENT_LOG ($spec): parse error at '$1'\n"; |
1137 | } |
1151 | } |
1138 | } |
1152 | } |