Skip to content

Commit 0a25b91

Browse files
committed
Added option to disable caller logging
1 parent f09fe75 commit 0a25b91

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/kotlin/org/javacs/kt/LogFormat.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ object LogFormat: Formatter() {
2222
}
2323

2424
private const val logTime = false
25+
private const val logCaller = false
2526
private var newline = System.lineSeparator()
2627
private val date = Date()
2728
private var maxSource = 0
@@ -32,13 +33,16 @@ object LogFormat: Formatter() {
3233
val time = if (logTime) "$date " else ""
3334

3435
var source: String
35-
if (record.sourceClassName != null) {
36+
val sourceWidth: Int
37+
if (logCaller && record.sourceClassName != null) {
3638
source = record.sourceClassName.split(".").last()
3739
if (record.sourceMethodName != null) {
3840
source += "." + record.sourceMethodName
3941
}
42+
sourceWidth = 45
4043
} else {
4144
source = record.loggerName
45+
sourceWidth = 6
4246
}
4347

4448
val message = formatMessage(record)
@@ -59,7 +63,7 @@ object LogFormat: Formatter() {
5963
2, // padding between columns
6064
FormatValue(prefix, 10),
6165
FormatValue(shortenOrPad(thread, 10)),
62-
FormatValue(source, 45),
66+
FormatValue(source, sourceWidth),
6367
FormatValue(message)
6468
) + throwable
6569
}

0 commit comments

Comments
 (0)