Log-Agent
view release on metacpan or search on metacpan
Agent/Tag/Callback.pm view on Meta::CPAN
sub string {
my $self = shift;
#
# Avoid recursion, which could happen if another logxxx() call is made
# whilst within the callback.
#
# Assumes mono-threaded application.
#
return sprintf 'callback "%s" busy', $self->name if $self->{busy};
$self->{busy} = 1;
my $string = $self->callback->call();
$self->{busy} = 0;
return $string;
}
1; # for "require"
__END__
=head1 NAME
Log::Agent::Tag::Callback - a dynamic tag string
Agent/Tag/Callback.pm view on Meta::CPAN
=head1 CREATION ROUTINE PARAMETERS
The following parameters are defined, in alphabetical order:
=over 4
=item C<-callback> => C<Callback> I<object>
The callback to invoke to determine the value of the tag. The call is
protected via a I<busy> flag, in case there is an unwanted recursion due
to a call to one of the logging routines whilst within the callback.
If the callback is busy, the tag emitted is:
callback "user" busy
assuming C<user> is the name you supplied via C<-name> for this tag.
=item C<-name> => I<name>
The name of this tag. Used to flag a callback as I<busy> in case there is
an unwanted recursion into the callback routine.
=item C<-postfix> => I<flag>
Whether tag should be placed after or before the log message.
By default, it is prepended to the log message, i.e. this parameter is false.
=item C<-separator> => I<string>
The separation string between the tag and the log message.
( run in 0.241 second using v1.01-cache-2.11-cpan-87723dcf8b7 )