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.29 by root, Thu Aug 25 00:14:32 2011 UTC vs.
Revision 1.30 by root, Thu Aug 25 00:24:47 2011 UTC

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
972A context name in the log specification can be any of the following:
973
974=over 4
975
976=item C<collect>, C<filter>, C<log>
977
978Correspond to the three predefined C<$AnyEvent::Log::COLLECT>,
979C<AnyEvent::Log::FILTER> and C<$AnyEvent::Log::LOG> contexts.
980
981=item C<%name>
982
983Context names starting with a C<%> are anonymous contexts created when the
984name is first mentioned. The difference to package contexts is that by
985default they have no attached slaves.
986
987=item a perl package name
988
989Any other string references the logging context associated with the given
990Perl C<package>. In the unlikely case where you want to specify a package
991context that matches on of the other context name forms, you can add a
992C<::> to the package name to force interpretation as a package.
993
994=back
995
996The configuration specifications can be any number of the following:
997
998=over 4
999
1000=item C<stderr>
1001
1002Configures the context to use Perl's C<warn> function (which typically
1003logs to C<STDERR>). Works like C<log_to_warn>.
1004
1005=item C<file=>I<path>
1006
1007Configures the context to log to a file with the given path. Works like
1008C<log_to_file>.
1009
1010=item C<path=>I<path>
1011
1012Configures the context to log to a file with the given path. Works like
1013C<log_to_path>.
1014
1015=item C<syslog> or C<syslog=>I<expr>
1016
1017Configured the context to log to syslog. If I<expr> is given, then it is
1018evaluated in the L<Sys::Syslog> package, so you could use:
1019
1020 log=syslog=LOG_LOCAL0
1021
1022=item C<nolog>
1023
1024Configures the context to not log anything by itself, which is the
1025default. Same as C<< $ctx->log_cb (undef) >>.
1026
1027=item C<0> or C<off>
1028
1029Sets the logging level of the context ot C<0>, i.e. all messages will be
1030filtered out.
1031
1032=item C<all>
1033
1034Enables all logging levels, i.e. filtering will effectively be switched
1035off (the default).
1036
1037=item C<only>
1038
1039Disables all logging levels, and changes the interpretation of following
1040level specifications to enable the specified level only.
1041
1042Example: only enable debug messages for a context.
1043
1044 context=only,debug
1045
1046=item C<except>
1047
1048Enables all logging levels, and changes the interpretation of following
1049level specifications to disable that level. Rarely used.
1050
1051Example: enable all logging levels except fatal and trace (this is rather
1052nonsensical).
1053
1054 filter=exept,fatal,trace
1055
1056=item C<level>
1057
1058Enables all logging levels, and changes the interpretation of following
1059level specifications to be "that level or any higher priority
1060message". This is the default.
1061
1062Example: log anything at or above warn level.
1063
1064 filter=warn
1065
1066 # or, more verbose
1067 filter=only,level,warn
1068
1069=item C<1>..C<9>, a logging level name (C<error>, C<debug> etc.)
1070
1071A numeric loglevel or the name of a loglevel will be interpreted according
1072to the most recent C<only>, C<except> or C<level> directive. By default,
1073specifying a logging level enables that and any higher priority messages.
1074
1075=item C<+>I<context>
1076
1077Adds/attaches the named context as slave to the context.
1078
1079=item C<+>
1080
1081A line C<+> clears the slave list form the context. Anonymous (C<%name>)
1082contexts have no slaves by default, but package contexts have the parent
1083context as slave by default.
1084
1085Example: log messages from My::Module to a file, do not send them to the
1086default log collector.
1087
1088 My::Module=+,file=/tmp/mymodulelog
1089
1090=back
1091
1092Any character can be escaped by prefixing it with a C<\> (backslash), as
1093usual, so to log to a file containing a comma, colon, backslash and space in the
1094filename, you would do this:
1095
1096 PERL_ANYEVENT_LOG='log=file=/some\ \:file\ with\,\ \\-escapes'
1097
972Since whitespace (which includes newlines) is allowed, it is fine to 1098Since whitespace (which includes newlines) is allowed, it is fine to
973specify multiple lines in C<PERL_ANYEVENT_LOG>, e.g.: 1099specify multiple lines in C<PERL_ANYEVENT_LOG>, e.g.:
974 1100
975 PERL_ANYEVENT_LOG=" 1101 PERL_ANYEVENT_LOG="
976 filter=warn 1102 filter=warn
977 AnyEvent::Debug=+%trace 1103 AnyEvent::Debug=+%trace
978 %trace=only,trace,+log 1104 %trace=only,trace,+log
979 " myprog 1105 " myprog
980 1106
981A context name in the log specification can be any of the following: 1107Also, in the unlikely case when you want to concatenate specifications,
1108use whitespace as separator, as C<::> will be interpreted as part of a
1109module name, an empty spec with two separators:
982 1110
983=over 4 1111 PERL_ANYEVENT_LOG="$PERL_ANYEVENT_LOG MyMod=debug"
984
985=item C<collect>, C<filter>, C<log>
986
987Correspond to the three predefined C<$AnyEvent::Log::COLLECT>,
988C<AnyEvent::Log::FILTER> and C<$AnyEvent::Log::LOG> contexts.
989
990=item C<%name>
991
992Context names starting with a C<%> are anonymous contexts created when the
993name is first mentioned. The difference to package contexts is that by
994default they have no attached slaves.
995
996=item a perl package name
997
998Any other string references the logging context associated with the given
999Perl C<package>. In the unlikely case where you want to specify a package
1000context that matches on of the other context name forms, you can add a
1001C<::> to the package name to force interpretation as a package.
1002
1003=back
1004
1005The configuration specifications can be any number of the following:
1006
1007=over 4
1008
1009=item C<stderr>
1010
1011Configures the context to use Perl's C<warn> function (which typically
1012logs to C<STDERR>). Works like C<log_to_warn>.
1013
1014=item C<file=>I<path>
1015
1016Configures the context to log to a file with the given path. Works like
1017C<log_to_file>.
1018
1019=item C<path=>I<path>
1020
1021Configures the context to log to a file with the given path. Works like
1022C<log_to_path>.
1023
1024=item C<syslog> or C<syslog=>I<expr>
1025
1026Configured the context to log to syslog. If I<expr> is given, then it is
1027evaluated in the L<Sys::Syslog> package, so you could use:
1028
1029 log=syslog=LOG_LOCAL0
1030
1031=item C<nolog>
1032
1033Configures the context to not log anything by itself, which is the
1034default. Same as C<< $ctx->log_cb (undef) >>.
1035
1036=item C<0> or C<off>
1037
1038Sets the logging level of the context ot C<0>, i.e. all messages will be
1039filtered out.
1040
1041=item C<all>
1042
1043Enables all logging levels, i.e. filtering will effectively be switched
1044off (the default).
1045
1046=item C<only>
1047
1048Disables all logging levels, and changes the interpretation of following
1049level specifications to enable the specified level only.
1050
1051Example: only enable debug messages for a context.
1052
1053 context=only,debug
1054
1055=item C<except>
1056
1057Enables all logging levels, and changes the interpretation of following
1058level specifications to disable that level. Rarely used.
1059
1060Example: enable all logging levels except fatal and trace (this is rather
1061nonsensical).
1062
1063 filter=exept,fatal,trace
1064
1065=item C<level>
1066
1067Enables all logging levels, and changes the interpretation of following
1068level specifications to be "that level or any higher priority
1069message". This is the default.
1070
1071Example: log anything at or above warn level.
1072
1073 filter=warn
1074
1075 # or, more verbose
1076 filter=only,level,warn
1077
1078=item C<1>..C<9>, a logging level name (C<error>, C<debug> etc.)
1079
1080A numeric loglevel or the name of a loglevel will be interpreted according
1081to the most recent C<only>, C<except> or C<level> directive. By default,
1082specifying a logging level enables that and any higher priority messages.
1083
1084=item C<+>I<context>
1085
1086Adds/attaches the named context as slave to the context.
1087
1088=item C<+>
1089
1090A line C<+> clears the slave list form the context. Anonymous (C<%name>)
1091contexts have no slaves by default, but package contexts have the parent
1092context as slave by default.
1093
1094Example: log messages from My::Module to a file, do not send them to the
1095default log collector.
1096
1097 My::Module=+,file=/tmp/mymodulelog
1098
1099=back
1100 1112
1101=cut 1113=cut
1102 1114
1103for (my $spec = $ENV{PERL_ANYEVENT_LOG}) { 1115for (my $spec = $ENV{PERL_ANYEVENT_LOG}) {
1104 my %anon; 1116 my %anon;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines