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

Comparing AnyEvent/lib/AnyEvent/Log.pm (file contents):
Revision 1.27 by root, Wed Aug 24 23:59:10 2011 UTC vs.
Revision 1.28 by root, Thu Aug 25 00:08:10 2011 UTC

1139 1139
11401; 11401;
1141 1141
1142=head1 EXAMPLES 1142=head1 EXAMPLES
1143 1143
1144This section shows some common configurations. 1144This section shows some common configurations, both as code, and as
1145C<PERL_ANYEVENT_LOG> string.
1145 1146
1146=over 4 1147=over 4
1147 1148
1148=item Setting the global logging level. 1149=item Setting the global logging level.
1149 1150
1150Either put PERL_ANYEVENT_VERBOSE=<number> into your environment before 1151Either put C<PERL_ANYEVENT_VERBOSE=><number> into your environment before
1151running your program, or modify the log level of the root context: 1152running your program, use C<PERL_ANYEVENT_LOG> or modify the log level of
1153the root context at runtime:
1152 1154
1153 PERL_ANYEVENT_VERBOSE=5 ./myprog 1155 PERL_ANYEVENT_VERBOSE=5 ./myprog
1154 1156
1157 PERL_ANYEVENT_LOG=log=warn
1158
1155 $AnyEvent::Log::FILTER->level ("warn"); 1159 $AnyEvent::Log::FILTER->level ("warn");
1156 1160
1157=item Append all messages to a file instead of sending them to STDERR. 1161=item Append all messages to a file instead of sending them to STDERR.
1158 1162
1159This is affected by the global logging level. 1163This is affected by the global logging level.
1160 1164
1161 $AnyEvent::Log::LOG->log_to_file ($path); (sub { 1165 $AnyEvent::Log::LOG->log_to_file ($path);
1166
1167 PERL_ANYEVENT_LOG=log=file=/some/path
1162 1168
1163=item Write all messages with priority C<error> and higher to a file. 1169=item Write all messages with priority C<error> and higher to a file.
1164 1170
1165This writes them only when the global logging level allows it, because 1171This writes them only when the global logging level allows it, because
1166it is attached to the default context which is invoked I<after> global 1172it is attached to the default context which is invoked I<after> global
1167filtering. 1173filtering.
1168 1174
1169 $AnyEvent::Log::FILTER->attach 1175 $AnyEvent::Log::FILTER->attach
1170 new AnyEvent::Log::Ctx log_to_file => $path); 1176 new AnyEvent::Log::Ctx log_to_file => $path);
1171 1177
1178 PERL_ANYEVENT_LOG=filter=+%filelogger:%filelogger=file=/some/path
1179
1172This writes them regardless of the global logging level, because it is 1180This writes them regardless of the global logging level, because it is
1173attached to the toplevel context, which receives all messages I<before> 1181attached to the toplevel context, which receives all messages I<before>
1174the global filtering. 1182the global filtering.
1175 1183
1176 $AnyEvent::Log::COLLECT->attach ( 1184 $AnyEvent::Log::COLLECT->attach (
1177 new AnyEvent::Log::Ctx log_to_file => $path); 1185 new AnyEvent::Log::Ctx log_to_file => $path);
1178 1186
1187 PERL_ANYEVENT_LOG=%filelogger=file=/some/path:collect=+%filelogger
1188
1179In both cases, messages are still written to STDERR. 1189In both cases, messages are still written to STDERR.
1180 1190
1181=item Write trace messages (only) from L<AnyEvent::Debug> to the default logging target(s). 1191=item Write trace messages (only) from L<AnyEvent::Debug> to the default logging target(s).
1182 1192
1183Attach the C<$AnyEvent::Log::LOG> context to the C<AnyEvent::Debug> 1193Attach the C<$AnyEvent::Log::LOG> context to the C<AnyEvent::Debug>
1184context - this simply circumvents the global filtering for trace messages. 1194context - this simply circumvents the global filtering for trace messages.
1185 1195
1186 my $debug = AnyEvent::Debug->AnyEvent::Log::ctx; 1196 my $debug = AnyEvent::Debug->AnyEvent::Log::ctx;
1187 $debug->attach ($AnyEvent::Log::LOG); 1197 $debug->attach ($AnyEvent::Log::LOG);
1198
1199 PERL_ANYEVENT_LOG=AnyEvent::Debug=+log
1188 1200
1189This of course works for any package, not just L<AnyEvent::Debug>, but 1201This of course works for any package, not just L<AnyEvent::Debug>, but
1190assumes the log level for AnyEvent::Debug hasn't been changed from the 1202assumes the log level for AnyEvent::Debug hasn't been changed from the
1191default. 1203default.
1192 1204
1196 1208
1197 Marc Lehmann <schmorp@schmorp.de> 1209 Marc Lehmann <schmorp@schmorp.de>
1198 http://home.schmorp.de/ 1210 http://home.schmorp.de/
1199 1211
1200=cut 1212=cut
1213

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines