Skip to content

Commit

Permalink
Only report log matches repeats if --verbose-events.
Browse files Browse the repository at this point in the history
Only report the first log match event unless --verbose-events is
specified. If a service has some continuing chatty events (heartbeats or
usage stats for example), the typical use case is that the first
occurence is the important one. This also makes non-TUI event logging
match the TUI representation better too.
  • Loading branch information
kanaka committed Jun 4, 2024
1 parent 254f5cf commit 32490a5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/dcmon/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Options:
EVTS is comma separated list of events types or 'all'
--columns COLS COLS is comma separated list of columns to display
[default: 'container,logs,checks']
--verbose-events Show full docker events
--verbose-events Show full docker events and repeated log matches
--no-tui Disable TUI (ink/React) visual representation
--timeout TIMEOUT Timeout after TIMEOUT seconds
(exit with error if not in finished state)
Expand Down Expand Up @@ -393,7 +393,8 @@ Options:
logs for this container. If the log message matches a log check then
mark it done."
[service cidx chnk]
(let [{:keys [services containers]} @ctx
(let [{:keys [services containers settings]} @ctx
{:keys [verbose-events]} settings
{:keys [id checks log-lines log-regex]} (get-in services [service cidx])
log (.toString chnk "utf8")
new-checks (reduce (fn [checks {:keys [ts cindex]}]
Expand All @@ -402,7 +403,9 @@ Options:
:cidx cidx
:ts ts
:check check}]
(event :log-match log-base)
(when (or verbose-events
(not (:done? check)))
(event :log-match log-base))
(if (:done? check)
checks
(let [log (assoc-in log-base [:check :done?] true)]
Expand Down

0 comments on commit 32490a5

Please sign in to comment.