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 = '8.00';
20 55     55   24393 use Moo;
  55         159  
  55         313  
21             with 'Search::Elasticsearch::Role::Logger';
22 55     55   17401 use Search::Elasticsearch::Util qw(parse_params to_list);
  55         133  
  55         430  
23 55     55   20080 use namespace::clean;
  55         114  
  55         289  
24              
25 55     55   32993 use Log::Any 1.02 ();
  55         355523  
  55         1167  
26 55     55   17781 use Log::Any::Adapter();
  55         15950  
  55         10952  
27              
28             #===================================
29             sub _build_log_handle {
30             #===================================
31 99     99   5735 my $self = shift;
32 99 100       518 if ( my @args = to_list( $self->log_to ) ) {
33 3         25 Log::Any::Adapter->set( { category => $self->log_as }, @args );
34             }
35 99         4622 Log::Any->get_logger( category => $self->log_as );
36             }
37              
38             #===================================
39             sub _build_trace_handle {
40             #===================================
41 42     42   23913 my $self = shift;
42 42 100       265 if ( my @args = to_list( $self->trace_to ) ) {
43 3         24 Log::Any::Adapter->set( { category => $self->trace_as }, @args );
44             }
45 42         3959 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       8 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__