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.717';
20 55     55   21544 use Moo;
  55         107  
  55         300  
21             with 'Search::Elasticsearch::Role::Logger';
22 55     55   14669 use Search::Elasticsearch::Util qw(parse_params to_list);
  55         109  
  55         425  
23 55     55   18033 use namespace::clean;
  55         103  
  55         291  
24              
25 55     55   27936 use Log::Any 1.02 ();
  55         293493  
  55         1037  
26 55     55   15455 use Log::Any::Adapter();
  55         12841  
  55         8947  
27              
28             #===================================
29             sub _build_log_handle {
30             #===================================
31 99     99   4731 my $self = shift;
32 99 100       506 if ( my @args = to_list( $self->log_to ) ) {
33 3         25 Log::Any::Adapter->set( { category => $self->log_as }, @args );
34             }
35 99         4092 Log::Any->get_logger( category => $self->log_as );
36             }
37              
38             #===================================
39             sub _build_trace_handle {
40             #===================================
41 42     42   21141 my $self = shift;
42 42 100       258 if ( my @args = to_list( $self->trace_to ) ) {
43 3         20 Log::Any::Adapter->set( { category => $self->trace_as }, @args );
44             }
45 42         1983 Log::Any->get_logger( category => $self->trace_as );
46             }
47              
48             #===================================
49             sub _build_deprecate_handle {
50             #===================================
51 1     1   10 my $self = shift;
52 1 50       6 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         9 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__