|
1
|
|
package org.europa.together.application; |
|
2
|
|
|
|
3
|
|
import java.io.File; |
|
4
|
|
import java.util.Arrays; |
|
5
|
|
import org.europa.together.business.Logger; |
|
6
|
|
import org.europa.together.domain.LogLevel; |
|
7
|
|
import org.europa.together.utils.Constraints; |
|
8
|
|
import org.slf4j.LoggerFactory; |
|
9
|
|
|
|
10
|
|
/** |
|
11
|
|
* Implementation of the Logger as Wrapper for SLF4j and logback Framework. |
|
12
|
|
*/ |
|
13
|
|
//@Repository |
|
14
|
|
public class LogbackLogger implements Logger { |
|
15
|
|
|
|
16
|
|
private static final long serialVersionUID = 1L; |
|
17
|
|
private final String configurationFile = Constraints.SYSTEM_APP_DIR + "/logback.xml"; |
|
18
|
|
private Class<?> instance = null; |
|
19
|
|
private org.slf4j.Logger logger = null; |
|
20
|
|
|
|
21
|
|
/** |
|
22
|
|
* Create an instance of the logging class. THe configuration file will be |
|
23
|
|
* searched in the Directory, where the application is running.<br> |
|
24
|
|
* |
|
25
|
|
* see: org/europa/together/configuration/logback.xml If is no configuration |
|
26
|
|
* present at this position, the logger use the default configuration in the |
|
27
|
|
* classpath, with the console appender. |
|
28
|
|
* |
|
29
|
|
* @param instance The instance of the logged CLASS |
|
30
|
|
*/ |
|
31
|
|
public LogbackLogger(final Class<?> instance) { |
|
32
|
|
this.instance = instance; |
|
33
|
|
|
|
34
|
|
//FALLBACK |
|
35
|
1
1. <init> : negated conditional → SURVIVED
|
if (new File(configurationFile).exists()) { |
|
36
|
|
System.setProperty("configurationFile", configurationFile); |
|
37
|
|
} |
|
38
|
|
} |
|
39
|
|
|
|
40
|
|
@Override |
|
41
|
|
public LogLevel log(final String message, final LogLevel level) { |
|
42
|
1
1. log : removed call to org/europa/together/application/LogbackLogger::instanceLogger → KILLED
|
instanceLogger(); |
|
43
|
|
switch (level) { |
|
44
|
|
case TRACE: |
|
45
|
|
logger.trace(message); |
|
46
|
|
break; |
|
47
|
|
case DEBUG: |
|
48
|
|
logger.debug(message); |
|
49
|
|
break; |
|
50
|
|
case INFO: |
|
51
|
|
logger.info(message); |
|
52
|
|
break; |
|
53
|
|
case WARN: |
|
54
|
|
logger.warn(message); |
|
55
|
|
break; |
|
56
|
|
default: |
|
57
|
|
logger.error(message); |
|
58
|
|
break; |
|
59
|
|
} |
|
60
|
1
1. log : replaced return value with null for org/europa/together/application/LogbackLogger::log → KILLED
|
return level; |
|
61
|
|
} |
|
62
|
|
|
|
63
|
|
public String getLoggerName() { |
|
64
|
|
return logger.getName(); |
|
65
|
|
} |
|
66
|
|
|
|
67
|
|
@Override |
|
68
|
|
public LogLevel getConfiguredLogLevel() { |
|
69
|
1
1. getConfiguredLogLevel : removed call to org/europa/together/application/LogbackLogger::instanceLogger → SURVIVED
|
instanceLogger(); |
|
70
|
|
LogLevel level = null; |
|
71
|
|
if (logger.isErrorEnabled()) { |
|
72
|
|
level = LogLevel.ERROR; |
|
73
|
|
} |
|
74
|
|
if (logger.isWarnEnabled()) { |
|
75
|
|
level = LogLevel.WARN; |
|
76
|
|
} |
|
77
|
|
if (logger.isInfoEnabled()) { |
|
78
|
|
level = LogLevel.INFO; |
|
79
|
|
} |
|
80
|
|
if (logger.isDebugEnabled()) { |
|
81
|
|
level = LogLevel.DEBUG; |
|
82
|
|
} |
|
83
|
|
if (logger.isTraceEnabled()) { |
|
84
|
|
level = LogLevel.TRACE; |
|
85
|
|
} |
|
86
|
1
1. getConfiguredLogLevel : replaced return value with null for org/europa/together/application/LogbackLogger::getConfiguredLogLevel → KILLED
|
return level; |
|
87
|
|
} |
|
88
|
|
|
|
89
|
|
@Override |
|
90
|
|
public String catchException(final Exception ex) { |
|
91
|
1
1. catchException : removed call to org/europa/together/application/LogbackLogger::instanceLogger → KILLED
|
instanceLogger(); |
|
92
|
|
String exceptionType = ex.getClass().getSimpleName(); |
|
93
|
|
logger.error(exceptionType + ": " + ex.getMessage()); |
|
94
|
1
1. catchException : negated conditional → SURVIVED
|
if (exceptionType.equals("NullPointerException")) { |
|
95
|
|
logger.error(Arrays.toString(ex.getStackTrace())); |
|
96
|
|
} |
|
97
|
1
1. catchException : replaced return value with "" for org/europa/together/application/LogbackLogger::catchException → KILLED
|
return ex.getMessage(); |
|
98
|
|
} |
|
99
|
|
|
|
100
|
|
private void instanceLogger() { |
|
101
|
1
1. instanceLogger : negated conditional → KILLED
|
if (logger == null) { |
|
102
|
|
logger = LoggerFactory.getILoggerFactory().getLogger(instance.getName()); |
|
103
|
|
} |
|
104
|
|
} |
|
105
|
|
} |
| | Mutations |
| 35 |
|
1.1 Location : <init> Killed by : none negated conditional → SURVIVED
Covering tests
Covered by tests:
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:logDebug()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:logInfo()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:logError()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:logWarn()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:logTrace()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:failLog()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:catchNullpointerException()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:catchException()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:getLoggerName()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:fallbackConstructor()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:constructor()]
- org.europa.together.utils.ConstraintsTest.[engine:junit-jupiter]/[class:org.europa.together.utils.ConstraintsTest]/[method:privateConstructor()]
- org.europa.together.domain.MailTest.[engine:junit-jupiter]/[class:org.europa.together.domain.MailTest]/[method:subject()]
- org.europa.together.domain.JdbcConnectionTest.[engine:junit-jupiter]/[class:org.europa.together.domain.JdbcConnectionTest]/[method:privateConstructor()]
- org.europa.together.service.LoggingServiceTest.[engine:junit-jupiter]/[class:org.europa.together.service.LoggingServiceTest]/[method:constructor()]
- org.europa.together.application.VelocityRendererTest.[engine:junit-jupiter]/[class:org.europa.together.application.VelocityRendererTest]/[method:constructor()]
- org.europa.together.application.ZxingGeneratorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ZxingGeneratorTest]/[method:constructor()]
- org.europa.together.utils.ValidatorTest.[engine:junit-jupiter]/[class:org.europa.together.utils.ValidatorTest]/[method:isDateNotInRange_NullPointer()]
- org.europa.together.domain.TreeNodeTest.[engine:junit-jupiter]/[class:org.europa.together.domain.TreeNodeTest]/[method:equalByDiffrentUuid()]
- org.europa.together.domain.VersionTest.[engine:junit-jupiter]/[class:org.europa.together.domain.VersionTest]/[method:failGetVersion_Minor()]
- org.europa.together.utils.FileUtilsTest.[engine:junit-jupiter]/[class:org.europa.together.utils.FileUtilsTest]/[method:appendFile()]
- org.europa.together.utils.StringUtilsTest.[engine:junit-jupiter]/[class:org.europa.together.utils.StringUtilsTest]/[method:shrinkContent()]
- org.europa.together.domain.JpaPaginationTest.[engine:junit-jupiter]/[class:org.europa.together.domain.JpaPaginationTest]/[method:domainObject()]
- org.europa.together.application.JacksonJsonToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JacksonJsonToolsTest]/[method:failDeserializeJsonToObject()]
- org.europa.together.application.PropertyFileReaderTest.[engine:junit-jupiter]/[class:org.europa.together.application.PropertyFileReaderTest]/[method:addProperty()]
- org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:validationEmptyValue()]
- org.europa.together.application.ListTreeTest.[engine:junit-jupiter]/[class:org.europa.together.application.ListTreeTest]/[method:failValidateTreeNodeWithDisconnectedParent()]
- org.europa.together.application.DaoPaginationTest.[engine:junit-jupiter]/[class:org.europa.together.application.DaoPaginationTest]/[method:fetchLessResultsThanAPage()]
- org.europa.together.application.JdbcActionsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JdbcActionsTest]/[method:getResultSet()]
- org.europa.together.application.SaxToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.SaxToolsTest]/[method:invalidDtd()]
- org.europa.together.service.MailClientServiceTest.[engine:junit-jupiter]/[class:org.europa.together.service.MailClientServiceTest]/[method:constructor()]
- org.europa.together.application.NimbusJwtTest.[engine:junit-jupiter]/[class:org.europa.together.application.NimbusJwtTest]/[method:constructor()]
- org.europa.together.service.ConfigurationServiceTest.[engine:junit-jupiter]/[class:org.europa.together.service.ConfigurationServiceTest]/[method:constructor()]
- org.europa.together.application.JakartaMailClientTest.[engine:junit-jupiter]/[class:org.europa.together.application.JakartaMailClientTest]/[method:getMailObject()]
- org.europa.together.application.ImgSclrProcessorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ImgSclrProcessorTest]/[method:resizeImageReduce()]
- org.europa.together.application.FeatureFlagsFF4jTest.[engine:junit-jupiter]/[class:org.europa.together.application.FeatureFlagsFF4jTest]/[method:updateFeatureNotExist()]
- org.europa.together.application.OpenPdfRendererTest.[engine:junit-jupiter]/[class:org.europa.together.application.OpenPdfRendererTest]/[method:includeLocalImages()]
- org.europa.together.application.ConfigurationHbmDAOTest.[engine:junit-jupiter]/[class:org.europa.together.application.ConfigurationHbmDAOTest]/[method:updateNotExist()]
- org.europa.together.application.JavaCryptoToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JavaCryptoToolsTest]/[method:writeKeyPairToFile()]
|
| 42 |
|
1.1 Location : log Killed by : org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:logDebug()] removed call to org/europa/together/application/LogbackLogger::instanceLogger → KILLED
|
| 60 |
|
1.1 Location : log Killed by : org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:logDebug()] replaced return value with null for org/europa/together/application/LogbackLogger::log → KILLED
|
| 69 |
|
1.1 Location : getConfiguredLogLevel Killed by : none removed call to org/europa/together/application/LogbackLogger::instanceLogger → SURVIVED
Covering tests
Covered by tests:
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:getLogLevel()]
|
| 86 |
|
1.1 Location : getConfiguredLogLevel Killed by : org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:getLogLevel()] replaced return value with null for org/europa/together/application/LogbackLogger::getConfiguredLogLevel → KILLED
|
| 91 |
|
1.1 Location : catchException Killed by : org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:catchNullpointerException()] removed call to org/europa/together/application/LogbackLogger::instanceLogger → KILLED
|
| 94 |
|
1.1 Location : catchException Killed by : none negated conditional → SURVIVED
Covering tests
Covered by tests:
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:catchNullpointerException()]
- org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:catchException()]
- org.europa.together.utils.StringUtilsTest.[engine:junit-jupiter]/[class:org.europa.together.utils.StringUtilsTest]/[method:failDecodeBase64Url()]
- org.europa.together.application.SaxToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.SaxToolsTest]/[method:failParseXmlString()]
- org.europa.together.application.SaxToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.SaxToolsTest]/[method:failParsingXmlFile()]
- org.europa.together.application.ImgSclrProcessorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ImgSclrProcessorTest]/[method:failFlipVertical()]
- org.europa.together.application.JavaCryptoToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JavaCryptoToolsTest]/[method:failLoadPublicKeyFile()]
- org.europa.together.application.JavaCryptoToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JavaCryptoToolsTest]/[method:failLoadPrivateKeyFile()]
- org.europa.together.application.JavaCryptoToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JavaCryptoToolsTest]/[method:failGenerateRandomDoubleValue()]
- org.europa.together.application.JavaCryptoToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JavaCryptoToolsTest]/[method:failCalculateHashes()]
- org.europa.together.application.JavaCryptoToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JavaCryptoToolsTest]/[method:failCalculateKeyPair()]
- org.europa.together.application.ImgSclrProcessorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ImgSclrProcessorTest]/[method:failFlipHorizontal()]
- org.europa.together.application.SaxToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.SaxToolsTest]/[method:failPrettyPrint()]
- org.europa.together.application.ImgSclrProcessorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ImgSclrProcessorTest]/[method:failSaveImage()]
- org.europa.together.application.SaxToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.SaxToolsTest]/[method:failTransformation()]
- org.europa.together.application.JavaCryptoToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JavaCryptoToolsTest]/[method:failWriteKeyPairToFile()]
- org.europa.together.application.ImgSclrProcessorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ImgSclrProcessorTest]/[method:failImageRotate()]
- org.europa.together.application.ImgSclrProcessorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ImgSclrProcessorTest]/[method:failResize()]
- org.europa.together.application.ZxingGeneratorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ZxingGeneratorTest]/[method:failDecode()]
- org.europa.together.application.ZxingGeneratorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ZxingGeneratorTest]/[method:failEncode()]
- org.europa.together.application.SaxToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.SaxToolsTest]/[method:failValidation()]
- org.europa.together.application.ImgSclrProcessorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ImgSclrProcessorTest]/[method:failLoadImage()]
- org.europa.together.application.PropertyFileReaderTest.[engine:junit-jupiter]/[class:org.europa.together.application.PropertyFileReaderTest]/[method:failUpdateProperty()]
- org.europa.together.application.JakartaMailClientTest.[engine:junit-jupiter]/[class:org.europa.together.application.JakartaMailClientTest]/[method:failLoadConfigurationFromPropertyFile()]
- org.europa.together.application.PropertyFileReaderTest.[engine:junit-jupiter]/[class:org.europa.together.application.PropertyFileReaderTest]/[method:failRemoveProperty()]
- org.europa.together.application.PropertyFileReaderTest.[engine:junit-jupiter]/[class:org.europa.together.application.PropertyFileReaderTest]/[method:updateProperty()]
- org.europa.together.application.PropertyFileReaderTest.[engine:junit-jupiter]/[class:org.europa.together.application.PropertyFileReaderTest]/[method:removeProperty()]
- org.europa.together.application.ImgSclrProcessorTest.[engine:junit-jupiter]/[class:org.europa.together.application.ImgSclrProcessorTest]/[method:failCropImage()]
- org.europa.together.application.JakartaMailClientTest.[engine:junit-jupiter]/[class:org.europa.together.application.JakartaMailClientTest]/[method:loadConfigurationFromClasspath()]
- org.europa.together.application.JdbcActionsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JdbcActionsTest]/[method:failConnect()]
- org.europa.together.application.JakartaMailClientTest.[engine:junit-jupiter]/[class:org.europa.together.application.JakartaMailClientTest]/[method:loadConfigurationFromFileSystem()]
- org.europa.together.application.JakartaMailClientTest.[engine:junit-jupiter]/[class:org.europa.together.application.JakartaMailClientTest]/[method:connectSMTPServer()]
- org.europa.together.service.LoggingServiceTest.[engine:junit-jupiter]/[class:org.europa.together.service.LoggingServiceTest]/[method:failWriteLogConfig()]
- org.europa.together.application.SaxToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.SaxToolsTest]/[method:noGrammar()]
- org.europa.together.application.SaxToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.SaxToolsTest]/[method:isNotWellFormed()]
- org.europa.together.application.JakartaMailClientTest.[engine:junit-jupiter]/[class:org.europa.together.application.JakartaMailClientTest]/[method:composeHtmlMail()]
- org.europa.together.application.PropertyFileReaderTest.[engine:junit-jupiter]/[class:org.europa.together.application.PropertyFileReaderTest]/[method:addProperty()]
- org.europa.together.application.JakartaMailClientTest.[engine:junit-jupiter]/[class:org.europa.together.application.JakartaMailClientTest]/[method:composeTextMail()]
- org.europa.together.application.JakartaMailClientTest.[engine:junit-jupiter]/[class:org.europa.together.application.JakartaMailClientTest]/[method:composeTextMailWithAttachment()]
- org.europa.together.application.SaxToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.SaxToolsTest]/[method:invalidSchema()]
- org.europa.together.application.FeatureFlagsFF4jTest.[engine:junit-jupiter]/[class:org.europa.together.application.FeatureFlagsFF4jTest]/[method:deactivatedFeatureStore()]
- org.europa.together.application.JdbcActionsTest.[engine:junit-jupiter]/[class:org.europa.together.application.JdbcActionsTest]/[method:sqlFileNotFound()]
- org.europa.together.application.JakartaMailClientTest.[engine:junit-jupiter]/[class:org.europa.together.application.JakartaMailClientTest]/[method:loadConfigurationFromDatabase()]
- org.europa.together.application.SaxToolsTest.[engine:junit-jupiter]/[class:org.europa.together.application.SaxToolsTest]/[method:invalidDtd()]
- org.europa.together.application.NimbusJwtTest.[engine:junit-jupiter]/[class:org.europa.together.application.NimbusJwtTest]/[method:constructor()]
- org.europa.together.application.FeatureFlagsFF4jTest.[engine:junit-jupiter]/[class:org.europa.together.application.FeatureFlagsFF4jTest]/[method:failConnectDatabase()]
- org.europa.together.application.ConfigurationHbmDAOTest.[engine:junit-jupiter]/[class:org.europa.together.application.ConfigurationHbmDAOTest]/[method:failUpdateConfigurationEntries()]
- org.europa.together.application.JakartaMailClientTest.[engine:junit-jupiter]/[class:org.europa.together.application.JakartaMailClientTest]/[method:getMailObject()]
- org.europa.together.application.ConfigurationHbmDAOTest.[engine:junit-jupiter]/[class:org.europa.together.application.ConfigurationHbmDAOTest]/[method:updateNotExist()]
|
| 97 |
|
1.1 Location : catchException Killed by : org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:catchNullpointerException()] replaced return value with "" for org/europa/together/application/LogbackLogger::catchException → KILLED
|
| 101 |
|
1.1 Location : instanceLogger Killed by : org.europa.together.application.LogbackLoggerTest.[engine:junit-jupiter]/[class:org.europa.together.application.LogbackLoggerTest]/[method:logDebug()] negated conditional → KILLED
|