From 26569f5131469e20fe908fe3404f548f8cddca74 Mon Sep 17 00:00:00 2001 From: Christian Walde Date: Thu, 21 Sep 2017 07:47:10 +0200 Subject: [PATCH] add slog to docs --- lib/Log/Contextual.pm | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/Log/Contextual.pm b/lib/Log/Contextual.pm index 95750f6..c9c8b2b 100644 --- a/lib/Log/Contextual.pm +++ b/lib/Log/Contextual.pm @@ -297,7 +297,7 @@ __END__ log_trace { 'foo entered' }; my ($foo, $bar) = Dlog_trace { "params for foo: $_" } @args; # ... - log_trace { 'foo left' }; + slog_trace 'foo left'; }; } @@ -326,7 +326,7 @@ Major benefits: =item * Efficient -The logging functions take blocks, so if a log level is disabled, the +The default logging functions take blocks, so if a log level is disabled, the block will not run: # the following won't run if debug is off @@ -591,6 +591,14 @@ B C does not call C for you, see L, but expects a string as first argument, +not a block. Arguments are passed through just the same, but since it's just a +string, interpolation of arguments into it must be done manually. + + my @friends = slog_trace 'friends list being generated.', generate_friend_list(); + =head2 logS_$level Import Tag: C<:log> @@ -607,6 +615,14 @@ same: See also: L. +=head2 slogS_$level + +Mostly the same as L, but expects a string as first argument, +not a block. Arguments are passed through just the same, but since it's just a +string, interpolation of arguments into it must be done manually. + + my $friend = slogS_trace 'I only have one friend.', friend(); + =head2 Dlog_$level Import Tag: C<:dlog> @@ -649,6 +665,15 @@ B C does not call C for you, see L, but expects a string as first argument, +not a block. Arguments are passed through just the same, but since it's just a +string, no interpolation point can be used, instead the Dumper output is +appended. + + my @nicks = Dslog_debug "names: ", map $_->value, $frew->names->all; + =head2 DlogS_$level Import Tag: C<:dlog> @@ -662,6 +687,16 @@ slurping up (and also setting C) all the C<@args> my $pals_rs = DlogS_debug { "pals resultset: $_" } $schema->resultset('Pals')->search({ perlers => 1 }); +=head2 DslogS_$level + +Mostly the same as L, but expects a string as first argument, +not a block. Arguments are passed through just the same, but since it's just a +string, no interpolation point can be used, instead the Dumper output is +appended. + + my $pals_rs = DslogS_debug "pals resultset: ", + $schema->resultset('Pals')->search({ perlers => 1 }); + =head1 LOGGER CODEREF Anywhere a logger object can be passed, a coderef is accepted. This is so