| 1 |
NAME |
| 2 |
Log::Any::Adapter::Callback - (DEPRECATED)(ADOPTME) Send Log::Any logs |
| 3 |
to a subroutine |
| 4 |
|
| 5 |
VERSION |
| 6 |
This document describes version 0.102 of Log::Any::Adapter::Callback |
| 7 |
(from Perl distribution Log-Any-Adapter-Callback), released on |
| 8 |
2023-11-21. |
| 9 |
|
| 10 |
SYNOPSIS |
| 11 |
# say, let's POST each log message to an HTTP API server |
| 12 |
use LWP::UserAgent; |
| 13 |
my $ua = LWP::UserAgent->new; |
| 14 |
|
| 15 |
use Log::Any::Adapter; |
| 16 |
Log::Any::Adapter->set('Callback', |
| 17 |
min_level => 'warn', |
| 18 |
logging_cb => sub { |
| 19 |
my ($method, $self, $format, @params) = @_; |
| 20 |
$ua->post("https://localdomain/log", level=>$method, Content=>$format); |
| 21 |
sleep 1; # don't overload the server |
| 22 |
}, |
| 23 |
detection_cb => sub { ... }, # optional, default is: sub { 1 } |
| 24 |
); |
| 25 |
|
| 26 |
DESCRIPTION |
| 27 |
DEPRECATION NOTICE: Log::Any distribution since 1.708 comes with |
| 28 |
Log::Any::Adapter::Capture which does the same thing. I'm deprecating |
| 29 |
this adapter now. |
| 30 |
|
| 31 |
This adapter lets you specify callback subroutine to be called by |
| 32 |
Log::Any's logging methods (like $log->debug(), $log->error(), etc) and |
| 33 |
detection methods (like $log->is_warning(), $log->is_fatal(), etc.). |
| 34 |
|
| 35 |
This adapter is used for customized logging, and is mostly a convenient |
| 36 |
construct to save a few lines of code. You could achieve the same effect |
| 37 |
by creating a full Log::Any adapter class. |
| 38 |
|
| 39 |
Your logging callback subroutine will be called with these arguments: |
| 40 |
|
| 41 |
($method, $self, $format, @params) |
| 42 |
|
| 43 |
where $method is the name of method (like "debug") and ($self, $format, |
| 44 |
@params) are given by Log::Any. |
| 45 |
|
| 46 |
HOMEPAGE |
| 47 |
Please visit the project's homepage at |
| 48 |
<https://metacpan.org/release/Log-Any-Adapter-Callback>. |
| 49 |
|
| 50 |
SOURCE |
| 51 |
Source repository is at |
| 52 |
<https://github.com/perlancar/perl-Log-Any-Adapter-Callback>. |
| 53 |
|
| 54 |
SEE ALSO |
| 55 |
Log::Any::Adapter::Capture |
| 56 |
|
| 57 |
Log::Any |
| 58 |
|
| 59 |
AUTHOR |
| 60 |
perlancar <[email protected]> |
| 61 |
|
| 62 |
CONTRIBUTOR |
| 63 |
Steven Haryanto <[email protected]> |
| 64 |
|
| 65 |
CONTRIBUTING |
| 66 |
To contribute, you can send patches by email/via RT, or send pull |
| 67 |
requests on GitHub. |
| 68 |
|
| 69 |
Most of the time, you don't need to build the distribution yourself. You |
| 70 |
can simply modify the code, then test via: |
| 71 |
|
| 72 |
% prove -l |
| 73 |
|
| 74 |
If you want to build the distribution (e.g. to try to install it locally |
| 75 |
on your system), you can install Dist::Zilla, |
| 76 |
Dist::Zilla::PluginBundle::Author::PERLANCAR, |
| 77 |
Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two |
| 78 |
other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps |
| 79 |
required beyond that are considered a bug and can be reported to me. |
| 80 |
|
| 81 |
COPYRIGHT AND LICENSE |
| 82 |
This software is copyright (c) 2023, 2020, 2014, 2013, 2012, 2011 by |
| 83 |
perlancar <[email protected]>. |
| 84 |
|
| 85 |
This is free software; you can redistribute it and/or modify it under |
| 86 |
the same terms as the Perl 5 programming language system itself. |
| 87 |
|
| 88 |
BUGS |
| 89 |
Please report any bugs or feature requests on the bugtracker website |
| 90 |
<https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Any-Adapter-Callb |
| 91 |
ack> |
| 92 |
|
| 93 |
When submitting a bug or request, please include a test-file or a patch |
| 94 |
to an existing test-file that illustrates the bug or desired feature. |
| 95 |
|