SimpleLogger.java

1
package fi.eis.libraries.di;
2
3
import java.io.PrintStream;
4
import java.util.Date;
5
6
public class SimpleLogger {
7
    public static enum LogLevel {
8
        NONE, ERROR, DEBUG; 
9
    }
10 1 1. <init> : Removed assignment to member variable logLevel → KILLED
    private volatile LogLevel logLevel = LogLevel.NONE;
11
12
    private final String className;
13 1 1. <init> : Removed assignment to member variable printStream → KILLED
    private transient PrintStream printStream = System.out;
14
15
    public SimpleLogger(Class<?> targetClass) {
16 2 1. <init> : removed call to java/lang/Class::getName → SURVIVED
2. <init> : Removed assignment to member variable className → SURVIVED
        this.className = targetClass.getName();
17
    }
18
    public void setLogLevel(LogLevel value) {
19 1 1. setLogLevel : Removed assignment to member variable logLevel → KILLED
        this.logLevel = value;
20
    }
21
    public boolean isDebugEnabled() {
22
        return this.logLevel.ordinal() >= LogLevel.DEBUG.ordinal();
23
    }
24
    public boolean isErrorEnabled() {
25
        return this.logLevel.ordinal() >= LogLevel.ERROR.ordinal();
26
    }
27
    
28
    public void debug(String message) {
29
        if (this.isDebugEnabled()) {
30 28 1. debug : removed call to java/util/Date::<init> → SURVIVED
2. debug : Substituted 3 with 4 → SURVIVED
3. debug : Substituted 0 with 1 → SURVIVED
4. debug : Substituted 1 with 0 → SURVIVED
5. debug : Substituted 0 with 1 → SURVIVED
6. debug : Substituted 2 with 1 → SURVIVED
7. debug : Substituted 1 with 0 → SURVIVED
8. debug : Substituted 2 with 0 → SURVIVED
9. debug : Substituted 3 with 4 → SURVIVED
10. debug : Substituted 0 with 1 → SURVIVED
11. debug : Substituted 1 with 2 → SURVIVED
12. debug : Substituted 1 with 0 → SURVIVED
13. debug : Substituted 2 with 1 → SURVIVED
14. debug : Substituted 2 with 3 → KILLED
15. debug : removed call to java/io/PrintStream::printf → KILLED
16. debug : replaced call to java/io/PrintStream::printf with receiver → KILLED
17. debug : Substituted 3 with 1 → KILLED
18. debug : Substituted 3 with 0 → KILLED
19. debug : Substituted 3 with -1 → KILLED
20. debug : Substituted 0 with -1 → KILLED
21. debug : Substituted 1 with -1 → KILLED
22. debug : Substituted 2 with -1 → KILLED
23. debug : Substituted 3 with -3 → KILLED
24. debug : Substituted 1 with -1 → KILLED
25. debug : Substituted 2 with -2 → KILLED
26. debug : Substituted 2 with 3 → KILLED
27. debug : Substituted 3 with 2 → KILLED
28. debug : Substituted 0 with -1 → KILLED
            printStream.printf("%s DEBUG %s: %s%n",
31
                    new Date(), className, message);
32
        }
33
    }
34
    public void debug(String message, Object... parameters) {
35
        if (this.isDebugEnabled()) {
36
            debug(String.format(message, parameters));
37
        }
38
    }
39
    public void error(String message) {
40
        if (this.isErrorEnabled()) {
41 28 1. error : removed call to java/util/Date::<init> → SURVIVED
2. error : Substituted 3 with 4 → SURVIVED
3. error : Substituted 0 with 1 → SURVIVED
4. error : Substituted 1 with 0 → SURVIVED
5. error : Substituted 0 with 1 → SURVIVED
6. error : Substituted 2 with 1 → SURVIVED
7. error : Substituted 1 with 0 → SURVIVED
8. error : Substituted 2 with 0 → SURVIVED
9. error : Substituted 3 with 4 → SURVIVED
10. error : Substituted 0 with 1 → SURVIVED
11. error : Substituted 1 with 2 → SURVIVED
12. error : Substituted 1 with 0 → SURVIVED
13. error : Substituted 2 with 1 → SURVIVED
14. error : Substituted 2 with 3 → KILLED
15. error : removed call to java/io/PrintStream::printf → KILLED
16. error : replaced call to java/io/PrintStream::printf with receiver → KILLED
17. error : Substituted 3 with 1 → KILLED
18. error : Substituted 3 with 0 → KILLED
19. error : Substituted 3 with -1 → KILLED
20. error : Substituted 0 with -1 → KILLED
21. error : Substituted 1 with -1 → KILLED
22. error : Substituted 2 with -1 → KILLED
23. error : Substituted 3 with -3 → KILLED
24. error : Substituted 1 with -1 → KILLED
25. error : Substituted 2 with -2 → KILLED
26. error : Substituted 2 with 3 → KILLED
27. error : Substituted 3 with 2 → KILLED
28. error : Substituted 0 with -1 → KILLED
            printStream.printf("%s ERROR %s: %s%n",
42
                    new Date(), className, message);
43
        }
44
    }
45
    public void error(String message, Object... parameters) {
46
        if (this.isErrorEnabled()) {
47
            error(String.format(message, parameters));
48
        }
49
    }
50
    /** package-private - we don't need to set this from everywhere */
51
    void setPrintOut(PrintStream stream) {
52 1 1. setPrintOut : Removed assignment to member variable printStream → KILLED
        this.printStream = stream;
53
    }
54
}

Mutations

10

1.1
Location : <init>
Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest)
Removed assignment to member variable logLevel → KILLED

13

1.1
Location : <init>
Killed by : fi.eis.libraries.di.DIClassScanningTest.testDiLoggingEnabled(fi.eis.libraries.di.DIClassScanningTest)
Removed assignment to member variable printStream → KILLED

16

1.1
Location : <init>
Killed by : none
removed call to java/lang/Class::getName → SURVIVED

2.2
Location : <init>
Killed by : none
Removed assignment to member variable className → SURVIVED

19

1.1
Location : setLogLevel
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Removed assignment to member variable logLevel → KILLED

30

1.1
Location : debug
Killed by : none
removed call to java/util/Date::<init> → SURVIVED

2.2
Location : debug
Killed by : none
Substituted 3 with 4 → SURVIVED

3.3
Location : debug
Killed by : none
Substituted 0 with 1 → SURVIVED

4.4
Location : debug
Killed by : none
Substituted 1 with 0 → SURVIVED

5.5
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 2 with 3 → KILLED

6.6
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
removed call to java/io/PrintStream::printf → KILLED

7.7
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
replaced call to java/io/PrintStream::printf with receiver → KILLED

8.8
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 3 with 1 → KILLED

9.9
Location : debug
Killed by : none
Substituted 0 with 1 → SURVIVED

10.10
Location : debug
Killed by : none
Substituted 2 with 1 → SURVIVED

11.11
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 3 with 0 → KILLED

12.12
Location : debug
Killed by : none
Substituted 1 with 0 → SURVIVED

13.13
Location : debug
Killed by : none
Substituted 2 with 0 → SURVIVED

14.14
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 3 with -1 → KILLED

15.15
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 0 with -1 → KILLED

16.16
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 1 with -1 → KILLED

17.17
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 2 with -1 → KILLED

18.18
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 3 with -3 → KILLED

19.19
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 1 with -1 → KILLED

20.20
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 2 with -2 → KILLED

21.21
Location : debug
Killed by : none
Substituted 3 with 4 → SURVIVED

22.22
Location : debug
Killed by : none
Substituted 0 with 1 → SURVIVED

23.23
Location : debug
Killed by : none
Substituted 1 with 2 → SURVIVED

24.24
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 2 with 3 → KILLED

25.25
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 3 with 2 → KILLED

26.26
Location : debug
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 0 with -1 → KILLED

27.27
Location : debug
Killed by : none
Substituted 1 with 0 → SURVIVED

28.28
Location : debug
Killed by : none
Substituted 2 with 1 → SURVIVED

41

1.1
Location : error
Killed by : none
removed call to java/util/Date::<init> → SURVIVED

2.2
Location : error
Killed by : none
Substituted 3 with 4 → SURVIVED

3.3
Location : error
Killed by : none
Substituted 0 with 1 → SURVIVED

4.4
Location : error
Killed by : none
Substituted 1 with 0 → SURVIVED

5.5
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 2 with 3 → KILLED

6.6
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
removed call to java/io/PrintStream::printf → KILLED

7.7
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
replaced call to java/io/PrintStream::printf with receiver → KILLED

8.8
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 3 with 1 → KILLED

9.9
Location : error
Killed by : none
Substituted 0 with 1 → SURVIVED

10.10
Location : error
Killed by : none
Substituted 2 with 1 → SURVIVED

11.11
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 3 with 0 → KILLED

12.12
Location : error
Killed by : none
Substituted 1 with 0 → SURVIVED

13.13
Location : error
Killed by : none
Substituted 2 with 0 → SURVIVED

14.14
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 3 with -1 → KILLED

15.15
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 0 with -1 → KILLED

16.16
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 1 with -1 → KILLED

17.17
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 2 with -1 → KILLED

18.18
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 3 with -3 → KILLED

19.19
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 1 with -1 → KILLED

20.20
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 2 with -2 → KILLED

21.21
Location : error
Killed by : none
Substituted 3 with 4 → SURVIVED

22.22
Location : error
Killed by : none
Substituted 0 with 1 → SURVIVED

23.23
Location : error
Killed by : none
Substituted 1 with 2 → SURVIVED

24.24
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 2 with 3 → KILLED

25.25
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 3 with 2 → KILLED

26.26
Location : error
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testErrorLevelErrorLogging(fi.eis.libraries.di.SimpleLoggerTest)
Substituted 0 with -1 → KILLED

27.27
Location : error
Killed by : none
Substituted 1 with 0 → SURVIVED

28.28
Location : error
Killed by : none
Substituted 2 with 1 → SURVIVED

52

1.1
Location : setPrintOut
Killed by : fi.eis.libraries.di.SimpleLoggerTest.testDebugLevelDebugLogging(fi.eis.libraries.di.SimpleLoggerTest)
Removed assignment to member variable printStream → KILLED

Active mutators

Tests examined


Report generated by PIT 1.6.7