… | |
… | |
894 | |
894 | |
895 | Replaces the formatting callback on the context (C<undef> restores the |
895 | Replaces the formatting callback on the context (C<undef> restores the |
896 | default formatter). |
896 | default formatter). |
897 | |
897 | |
898 | The callback is passed the (possibly fractional) timestamp, the original |
898 | The callback is passed the (possibly fractional) timestamp, the original |
899 | logging context, the (numeric) logging level and the raw message string |
899 | logging context (object, not title), the (numeric) logging level and |
900 | and needs to return a formatted log message. In most cases this will be a |
900 | the raw message string and needs to return a formatted log message. In |
901 | string, but it could just as well be an array reference that just stores |
901 | most cases this will be a string, but it could just as well be an array |
902 | the values. |
902 | reference that just stores the values. |
903 | |
903 | |
904 | If, for some reason, you want to use C<caller> to find out more about the |
904 | If, for some reason, you want to use C<caller> to find out more about the |
905 | logger then you should walk up the call stack until you are no longer |
905 | logger then you should walk up the call stack until you are no longer |
906 | inside the C<AnyEvent::Log> package. |
906 | inside the C<AnyEvent::Log> package. |
907 | |
907 | |
… | |
… | |
913 | |
913 | |
914 | "<$lvl>$msg\n" |
914 | "<$lvl>$msg\n" |
915 | }); |
915 | }); |
916 | |
916 | |
917 | Example: return an array reference with just the log values, and use |
917 | Example: return an array reference with just the log values, and use |
918 | C<PApp::SQL::sql_exec> to store the emssage in a database. |
918 | C<PApp::SQL::sql_exec> to store the message in a database. |
919 | |
919 | |
920 | $ctx->fmt_cb (sub { \@_ }); |
920 | $ctx->fmt_cb (sub { \@_ }); |
921 | $ctx->log_cb (sub { |
921 | $ctx->log_cb (sub { |
922 | my ($msg) = @_; |
922 | my ($msg) = @_; |
923 | |
923 | |