1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.velocity.internal.log

File AbstractSLF4JLogChute.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart5.png
76% of files have more coverage

Code metrics

0
54
3
1
111
76
18
0.33
18
3
6

Classes

Class Line # Actions
AbstractSLF4JLogChute 31 54 0% 18 30
0.4736842247.4%
 

Contributing tests

This file is covered by 14 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.velocity.internal.log;
21   
22    import org.apache.velocity.runtime.log.LogChute;
23    import org.slf4j.Logger;
24   
25    /**
26    * Based class for all SLF4J based implementation of {@link LogChute}.
27    *
28    * @version $Id: 6f91535aa90aa206cad2eea7eb7cb246552ea17d $
29    * @since 4.3M2
30    */
 
31    public abstract class AbstractSLF4JLogChute implements LogChute
32    {
33    /**
34    * @return the logger
35    */
36    protected abstract Logger getLogger();
37   
 
38  4557 toggle @Override
39    public void log(int level, String message)
40    {
41  4557 switch (level) {
42  103 case LogChute.WARN_ID:
43  103 getLogger().warn(message);
44  103 break;
45  0 case LogChute.INFO_ID:
46  0 getLogger().info(message);
47  0 break;
48  979 case LogChute.TRACE_ID:
49  979 getLogger().trace(message);
50  979 break;
51  78 case LogChute.ERROR_ID:
52  78 getLogger().error(message);
53  78 break;
54  3397 case LogChute.DEBUG_ID:
55  0 default:
56  3397 getLogger().debug(message);
57  3397 break;
58    }
59    }
60   
 
61  0 toggle @Override
62    public void log(int level, String message, Throwable t)
63    {
64  0 switch (level) {
65  0 case LogChute.WARN_ID:
66  0 getLogger().warn(message, t);
67  0 break;
68  0 case LogChute.INFO_ID:
69  0 getLogger().info(message, t);
70  0 break;
71  0 case LogChute.TRACE_ID:
72  0 getLogger().trace(message, t);
73  0 break;
74  0 case LogChute.ERROR_ID:
75  0 getLogger().error(message, t);
76  0 break;
77  0 case LogChute.DEBUG_ID:
78  0 default:
79  0 getLogger().debug(message, t);
80  0 break;
81    }
82    }
83   
 
84  4365460 toggle @Override
85    public boolean isLevelEnabled(int level)
86    {
87  4365476 boolean islevelEnabled;
88   
89  4365492 switch (level) {
90  3578698 case LogChute.DEBUG_ID:
91  3578694 islevelEnabled = getLogger().isDebugEnabled();
92  3578693 break;
93  0 case LogChute.INFO_ID:
94  0 islevelEnabled = getLogger().isInfoEnabled();
95  0 break;
96  61 case LogChute.TRACE_ID:
97  61 islevelEnabled = getLogger().isTraceEnabled();
98  61 break;
99  786726 case LogChute.WARN_ID:
100  786735 islevelEnabled = getLogger().isWarnEnabled();
101  786729 break;
102  0 case LogChute.ERROR_ID:
103  0 islevelEnabled = getLogger().isErrorEnabled();
104  0 break;
105  0 default:
106  0 islevelEnabled = true;
107    }
108   
109  4365475 return islevelEnabled;
110    }
111    }