File Coverage

blib/lib/Search/Elasticsearch/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             # Licensed to Elasticsearch B.V. under one or more contributor
2             # license agreements. See the NOTICE file distributed with
3             # this work for additional information regarding copyright
4             # ownership. Elasticsearch B.V. licenses this file to you under
5             # the Apache License, Version 2.0 (the "License"); you may
6             # not use this file except in compliance with the License.
7             # You may obtain a copy of the License at
8             #
9             # http://www.apache.org/licenses/LICENSE-2.0
10             #
11             # Unless required by applicable law or agreed to in writing,
12             # software distributed under the License is distributed on an
13             # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14             # KIND, either express or implied. See the License for the
15             # specific language governing permissions and limitations
16             # under the License.
17              
18             package Search::Elasticsearch::Logger::LogAny;
19             $Search::Elasticsearch::Logger::LogAny::VERSION = '7.715';
20 55     55   27464 use Moo;
  55         141  
  55         349  
21             with 'Search::Elasticsearch::Role::Logger';
22 55     55   17893 use Search::Elasticsearch::Util qw(parse_params to_list);
  55         158  
  55         523  
23 55     55   22475 use namespace::clean;
  55         122  
  55         364  
24              
25 55     55   35016 use Log::Any 1.02 ();
  55         372623  
  55         1303  
26 55     55   19812 use Log::Any::Adapter();
  55         16354  
  55         11626  
27              
28             #===================================
29             sub _build_log_handle {
30             #===================================
31 99     99   6029 my $self = shift;
32 99 100       665 if ( my @args = to_list( $self->log_to ) ) {
33 3         35 Log::Any::Adapter->set( { category => $self->log_as }, @args );
34             }
35 99         5824 Log::Any->get_logger( category => $self->log_as );
36             }
37              
38             #===================================
39             sub _build_trace_handle {
40             #===================================
41 42     42   26495 my $self = shift;
42 42 100       286 if ( my @args = to_list( $self->trace_to ) ) {
43 3         27 Log::Any::Adapter->set( { category => $self->trace_as }, @args );
44             }
45 42         2630 Log::Any->get_logger( category => $self->trace_as );
46             }
47              
48             #===================================
49             sub _build_deprecate_handle {
50             #===================================
51 1     1   14 my $self = shift;
52 1 50       9 if ( my @args = to_list( $self->deprecate_to ) ) {
53 0         0 Log::Any::Adapter->set( { category => $self->deprecate_as }, @args );
54             }
55             Log::Any->get_logger(
56 1         15 default_adapter => 'Stderr',
57             category => $self->deprecate_as
58             );
59             }
60              
61             1;
62              
63             # ABSTRACT: A Log::Any-based Logger implementation
64              
65             __END__