… | |
… | |
594 | |
594 | |
595 | =item $ctx = AnyEvent::Log::ctx [$pkg] |
595 | =item $ctx = AnyEvent::Log::ctx [$pkg] |
596 | |
596 | |
597 | This function creates or returns a logging context (which is an object). |
597 | This function creates or returns a logging context (which is an object). |
598 | |
598 | |
599 | If a package name is given, then the context for that packlage is |
599 | If a package name is given, then the context for that package is |
600 | returned. If it is called without any arguments, then the context for the |
600 | returned. If it is called without any arguments, then the context for the |
601 | callers package is returned (i.e. the same context as a C<AE::log> call |
601 | callers package is returned (i.e. the same context as a C<AE::log> call |
602 | would use). |
602 | would use). |
603 | |
603 | |
604 | If C<undef> is given, then it creates a new anonymous context that is not |
604 | If C<undef> is given, then it creates a new anonymous context that is not |
… | |
… | |
884 | sub attach { |
884 | sub attach { |
885 | my $ctx = shift; |
885 | my $ctx = shift; |
886 | |
886 | |
887 | $ctx->[2]{$_+0} = $_ |
887 | $ctx->[2]{$_+0} = $_ |
888 | for map { AnyEvent::Log::ctx $_ } @_; |
888 | for map { AnyEvent::Log::ctx $_ } @_; |
|
|
889 | AnyEvent::Log::_reassess; |
889 | } |
890 | } |
890 | |
891 | |
891 | sub detach { |
892 | sub detach { |
892 | my $ctx = shift; |
893 | my $ctx = shift; |
893 | |
894 | |
894 | delete $ctx->[2]{$_+0} |
895 | delete $ctx->[2]{$_+0} |
895 | for map { AnyEvent::Log::ctx $_ } @_; |
896 | for map { AnyEvent::Log::ctx $_ } @_; |
|
|
897 | AnyEvent::Log::_reassess; |
896 | } |
898 | } |
897 | |
899 | |
898 | sub slaves { |
900 | sub slaves { |
899 | undef $_[0][2]; |
901 | undef $_[0][2]; |
900 | &attach; |
902 | &attach; |
|
|
903 | AnyEvent::Log::_reassess; |
901 | } |
904 | } |
902 | |
905 | |
903 | =back |
906 | =back |
904 | |
907 | |
905 | =head3 LOG TARGETS |
908 | =head3 LOG TARGETS |