@@ -69,36 +69,32 @@ private val logLevel = ChildProcessLogLevel.Info
69
69
70
70
// Logging
71
71
private val dateFormatter: DateTimeFormatter = DateTimeFormatter .ofPattern(" HH:mm:ss.SSS" )
72
- private fun log (level : ChildProcessLogLevel , any : () -> Any? ) {
72
+ private inline fun log (level : ChildProcessLogLevel , any : () -> Any? ) {
73
73
if (level < logLevel)
74
74
return
75
75
76
- System .err.println (LocalDateTime .now().format(dateFormatter) + " | ${any()} " )
76
+ System .err.println (LocalDateTime .now().format(dateFormatter) + " ${level.name.uppercase()} | ${any()} " )
77
77
}
78
78
79
79
// errors that must be address
80
- private fun logError (any : () -> Any? ) {
80
+ internal inline fun logError (any : () -> Any? ) {
81
81
log(ChildProcessLogLevel .Error , any)
82
82
}
83
83
84
- private fun logException (e : Throwable ) {
85
- log(ChildProcessLogLevel .Error ) { " $e |> ${e.stackTraceToString()} " }
86
- }
87
-
88
84
// default log level for irregular useful messages that does not pollute log
89
- private fun logInfo (any : () -> Any? ) {
85
+ internal inline fun logInfo (any : () -> Any? ) {
90
86
log(ChildProcessLogLevel .Info , any)
91
87
}
92
88
93
89
// log level for frequent messages useful for debugging
94
- private fun logDebug (any : () -> Any? ) {
90
+ internal inline fun logDebug (any : () -> Any? ) {
95
91
log(ChildProcessLogLevel .Debug , any)
96
92
}
97
93
98
94
// log level for internal rd logs and frequent messages
99
95
// heavily pollutes log, useful only when debugging rpc
100
96
// probably contains no info about utbot
101
- private fun logTrace (any : () -> Any? ) {
97
+ internal fun logTrace (any : () -> Any? ) {
102
98
log(ChildProcessLogLevel .Trace , any)
103
99
}
104
100
@@ -193,7 +189,7 @@ private fun <T, R> RdCall<T, R>.measureExecutionForTermination(block: (T) -> R)
193
189
try {
194
190
block(it)
195
191
} catch (e: Throwable ) {
196
- logException(e)
192
+ logError { e.stackTraceToString() }
197
193
throw e
198
194
}
199
195
}
@@ -319,7 +315,6 @@ private suspend fun initiate(lifetime: Lifetime, port: Int, pid: Int) {
319
315
logInfo { " starting instrumenting" }
320
316
deferred.await()
321
317
} catch (e: Throwable ) {
322
- logError { " Terminating process because exception occurred" }
323
- logException(e)
318
+ logError { " Terminating process because exception occurred: ${e.stackTraceToString()} " }
324
319
}
325
320
}
0 commit comments