diff --git a/CHANGELOG.md b/CHANGELOG.md index dcdca6b1..54c3636c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,12 @@ * Improved the handling of track log timestamps - these can now be supplied by the client and are no longer bound to insert time of DB record. Latest Hoist React uses *start* of the tracked activity. +### ⚙️ Technical + +* Updated behavior of `withInfo` and `withDebug` log utils to print a "started" message if logging + enabled at `DEBUG` or `TRACE`, respectively. Allows admins to see start messages for more + important `withInfo` logs, without necessarily printing both lines for all `withDebug` calls. + ## 23.0.0 - 2024-09-27 ### 💥 Breaking Changes (upgrade difficulty: 🟢 LOW) diff --git a/src/main/groovy/io/xh/hoist/log/LogSupport.groovy b/src/main/groovy/io/xh/hoist/log/LogSupport.groovy index d70d8418..5a679c0d 100644 --- a/src/main/groovy/io/xh/hoist/log/LogSupport.groovy +++ b/src/main/groovy/io/xh/hoist/log/LogSupport.groovy @@ -126,7 +126,9 @@ trait LogSupport { private T loggedDo(Logger log, Level level, Object msgs, Closure c) { Map meta = getMeta() ?: [:]; - if (log.debugEnabled) { + // Log *start* of closure execution if at a fine run-time level. Use debug to get + // start msgs for your 'withInfo' logs, trace for your 'withDebug/withTrace' + if ((log.debugEnabled && level == INFO) || log.traceEnabled) { meta << [_status: 'started'] logAtLevel(log, level, msgs, meta) }