Skip to content

Commit

Permalink
Updated behavior of withInfo and withDebug (#414)
Browse files Browse the repository at this point in the history
* Updated behavior of `withInfo` and `withDebug`

+ Only log 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.

* Tweak approved by ATM

---------

Co-authored-by: lbwexler <lbwexler@xh.io>
  • Loading branch information
amcclain and lbwexler authored Oct 14, 2024
1 parent 64e85ee commit 5940b92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/main/groovy/io/xh/hoist/log/LogSupport.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ trait LogSupport {
private <T> T loggedDo(Logger log, Level level, Object msgs, Closure<T> 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)
}
Expand Down

0 comments on commit 5940b92

Please sign in to comment.