File Coverage

blib/lib/OpenSearch/Client/Logger/LogAny.pm
Criterion Covered Total %
statement 26 27 96.3
branch 5 6 83.3
condition n/a
subroutine 8 8 100.0
pod n/a
total 39 41 95.1


line stmt bran cond sub pod time code
1             # OpenSearch::Client is an unofficial client for OpenSearch.
2             # It is derived from Search::Elasticsearch version 7.714
3             # License details from the original work are contained in the
4             # NOTICE file distributed with this work.
5             #
6             #-----------------------------------------------------------------------
7             # OpenSearch::Client
8             #-----------------------------------------------------------------------
9             # Copyright 2026 Mark Dootson
10             #
11             # Licensed under the Apache License, Version 2.0 (the "License");
12             # you may not use this file except in compliance with the License.
13             # You may obtain a copy of the License at
14             #
15             # http://www.apache.org/licenses/LICENSE-2.0
16             #
17             # Unless required by applicable law or agreed to in writing, software
18             # distributed under the License is distributed on an "AS IS" BASIS,
19             # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20             # See the License for the specific language governing permissions and
21             # limitations under the License.
22              
23             package OpenSearch::Client::Logger::LogAny;
24             $OpenSearch::Client::Logger::LogAny::VERSION = '3.007002';
25 55     55   25024 use Moo;
  55         96  
  55         333  
26             with 'OpenSearch::Client::Role::Logger';
27 55     55   19096 use OpenSearch::Client::Util qw(parse_params to_list);
  55         144  
  55         336  
28 55     55   15956 use namespace::clean;
  55         88  
  55         307  
29              
30 55     55   31500 use Log::Any 1.02 ();
  55         335766  
  55         1264  
31 55     55   15439 use Log::Any::Adapter();
  55         16051  
  55         9631  
32              
33             #===================================
34             sub _build_log_handle {
35             #===================================
36 99     99   4822 my $self = shift;
37 99 100       1918 if ( my @args = to_list( $self->log_to ) ) {
38 3         28 Log::Any::Adapter->set( { category => $self->log_as }, @args );
39             }
40 99         6168 Log::Any->get_logger( category => $self->log_as );
41             }
42              
43             #===================================
44             sub _build_trace_handle {
45             #===================================
46 42     42   22469 my $self = shift;
47 42 100       252 if ( my @args = to_list( $self->trace_to ) ) {
48 3         24 Log::Any::Adapter->set( { category => $self->trace_as }, @args );
49             }
50 42         2211 Log::Any->get_logger( category => $self->trace_as );
51             }
52              
53             #===================================
54             sub _build_deprecate_handle {
55             #===================================
56 1     1   9 my $self = shift;
57 1 50       8 if ( my @args = to_list( $self->deprecate_to ) ) {
58 0         0 Log::Any::Adapter->set( { category => $self->deprecate_as }, @args );
59             }
60             Log::Any->get_logger(
61 1         14 default_adapter => 'Stderr',
62             category => $self->deprecate_as
63             );
64             }
65              
66             1;
67              
68             __END__