1Log::Any::Adapter::CallUbsaecrk(C3o)ntributed Perl DocumLeongt:a:tAinoyn::Adapter::Callback(3)
2
3
4
6 Log::Any::Adapter::Callback - (DEPRECATED) Send Log::Any logs to a
7 subroutine
8
10 This document describes version 0.101 of Log::Any::Adapter::Callback
11 (from Perl distribution Log-Any-Adapter-Callback), released on
12 2020-01-14.
13
15 # say, let's POST each log message to an HTTP API server
16 use LWP::UserAgent;
17 my $ua = LWP::UserAgent->new;
18
19 use Log::Any::Adapter;
20 Log::Any::Adapter->set('Callback',
21 min_level => 'warn',
22 logging_cb => sub {
23 my ($method, $self, $format, @params) = @_;
24 $ua->post("https://localdomain/log", level=>$method, Content=>$format);
25 sleep 1; # don't overload the server
26 },
27 detection_cb => sub { ... }, # optional, default is: sub { 1 }
28 );
29
31 DEPRECATION NOTICE: Log::Any distribution since 1.708 comes with
32 Log::Any::Adapter::Capture which does the same thing. I'm deprecating
33 this adapter now.
34
35 This adapter lets you specify callback subroutine to be called by
36 Log::Any's logging methods (like $log->debug(), $log->error(), etc) and
37 detection methods (like $log->is_warning(), $log->is_fatal(), etc.).
38
39 This adapter is used for customized logging, and is mostly a convenient
40 construct to save a few lines of code. You could achieve the same
41 effect by creating a full Log::Any adapter class.
42
43 Your logging callback subroutine will be called with these arguments:
44
45 ($method, $self, $format, @params)
46
47 where $method is the name of method (like "debug") and ($self, $format,
48 @params) are given by Log::Any.
49
51 Please visit the project's homepage at
52 <https://metacpan.org/release/Log-Any-Adapter-Callback>.
53
55 Source repository is at
56 <https://github.com/perlancar/perl-Log-Any-Adapter-Callback>.
57
59 Please report any bugs or feature requests on the bugtracker website
60 <https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Any-Adapter-Callback>
61
62 When submitting a bug or request, please include a test-file or a patch
63 to an existing test-file that illustrates the bug or desired feature.
64
66 Log::Any::Adapter::Capture
67
68 Log::Any
69
71 perlancar <perlancar@cpan.org>
72
74 This software is copyright (c) 2020, 2014, 2013, 2012, 2011 by
75 perlancar@cpan.org.
76
77 This is free software; you can redistribute it and/or modify it under
78 the same terms as the Perl 5 programming language system itself.
79
80
81
82perl v5.34.0 2022-01-21 Log::Any::Adapter::Callback(3)