1
1
package mu
2
2
3
- import mu.internal.toStringSafe
4
3
import org.slf4j.Logger
5
4
6
5
/* *
7
6
* An extension for [Logger] with Lazy message evaluation
8
7
* example:
9
8
* logger.info{"this is $lazy evaluated string"}
10
9
*/
11
- interface KLogger : Logger {
10
+ actual interface KLogger : Logger {
12
11
13
12
/* *
14
13
* The actual logger executing logging
@@ -18,70 +17,52 @@ interface KLogger : Logger {
18
17
/* *
19
18
* Lazy add a log message if isTraceEnabled is true
20
19
*/
21
- fun trace (msg : () -> Any? ) {
22
- if (isTraceEnabled) trace(msg.toStringSafe())
23
- }
20
+ actual fun trace (msg : () -> Any? )
24
21
25
22
/* *
26
23
* Lazy add a log message if isDebugEnabled is true
27
24
*/
28
- fun debug (msg : () -> Any? ) {
29
- if (isDebugEnabled) debug(msg.toStringSafe())
30
- }
25
+ actual fun debug (msg : () -> Any? )
31
26
32
27
/* *
33
28
* Lazy add a log message if isInfoEnabled is true
34
29
*/
35
- fun info (msg : () -> Any? ) {
36
- if (isInfoEnabled) info(msg.toStringSafe())
37
- }
30
+ actual fun info (msg : () -> Any? )
38
31
39
32
/* *
40
33
* Lazy add a log message if isWarnEnabled is true
41
34
*/
42
- fun warn (msg : () -> Any? ) {
43
- if (isWarnEnabled) warn(msg.toStringSafe())
44
- }
35
+ actual fun warn (msg : () -> Any? )
45
36
46
37
/* *
47
38
* Lazy add a log message if isErrorEnabled is true
48
39
*/
49
- fun error (msg : () -> Any? ) {
50
- if (isErrorEnabled) error(msg.toStringSafe())
51
- }
40
+ actual fun error (msg : () -> Any? )
52
41
53
42
/* *
54
43
* Lazy add a log message with throwable payload if isTraceEnabled is true
55
44
*/
56
- fun trace (t : Throwable ? , msg : () -> Any? ) {
57
- if (isTraceEnabled) trace(msg.toStringSafe(), t)
58
- }
45
+ actual fun trace (t : Throwable ? , msg : () -> Any? )
59
46
60
47
/* *
61
48
* Lazy add a log message with throwable payload if isDebugEnabled is true
62
49
*/
63
- fun debug (t : Throwable ? , msg : () -> Any? ) {
64
- if (isDebugEnabled) debug(msg.toStringSafe(), t)
65
- }
50
+ actual fun debug (t : Throwable ? , msg : () -> Any? )
66
51
67
52
/* *
68
53
* Lazy add a log message with throwable payload if isInfoEnabled is true
69
54
*/
70
- fun info (t : Throwable ? , msg : () -> Any? ) {
71
- if (isInfoEnabled) info(msg.toStringSafe(), t)
72
- }
55
+ actual fun info (t : Throwable ? , msg : () -> Any? )
73
56
74
57
/* *
75
58
* Lazy add a log message with throwable payload if isWarnEnabled is true
76
59
*/
77
- fun warn (t : Throwable ? , msg : () -> Any? ) {
78
- if (isWarnEnabled) warn(msg.toStringSafe(), t)
79
- }
60
+ actual fun warn (t : Throwable ? , msg : () -> Any? )
80
61
81
62
/* *
82
63
* Lazy add a log message with throwable payload if isErrorEnabled is true
83
64
*/
84
- fun error (t : Throwable ? , msg : () -> Any? ) {
85
- if (isErrorEnabled) error(msg.toStringSafe(), t)
86
- }
65
+ actual fun error (t : Throwable ? , msg : () -> Any? )
66
+
67
+
87
68
}
0 commit comments