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.007004';
25 55     55   25863 use Moo;
  55         99  
  55         303  
26             with 'OpenSearch::Client::Role::Logger';
27 55     55   19383 use OpenSearch::Client::Util qw(parse_params to_list);
  55         97  
  55         354  
28 55     55   17096 use namespace::clean;
  55         91  
  55         360  
29              
30 55     55   32032 use Log::Any 1.02 ();
  55         344034  
  55         1310  
31 55     55   15589 use Log::Any::Adapter();
  55         16505  
  55         9754  
32              
33             #===================================
34             sub _build_log_handle {
35             #===================================
36 99     99   4937 my $self = shift;
37 99 100       2071 if ( my @args = to_list( $self->log_to ) ) {
38 3         27 Log::Any::Adapter->set( { category => $self->log_as }, @args );
39             }
40 99         6890 Log::Any->get_logger( category => $self->log_as );
41             }
42              
43             #===================================
44             sub _build_trace_handle {
45             #===================================
46 42     42   22803 my $self = shift;
47 42 100       246 if ( my @args = to_list( $self->trace_to ) ) {
48 3         24 Log::Any::Adapter->set( { category => $self->trace_as }, @args );
49             }
50 42         2208 Log::Any->get_logger( category => $self->trace_as );
51             }
52              
53             #===================================
54             sub _build_deprecate_handle {
55             #===================================
56 1     1   10 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         12 default_adapter => 'Stderr',
62             category => $self->deprecate_as
63             );
64             }
65              
66             1;
67              
68             __END__