Files
coredns/plugin
cangming cad961f75f plugin/errors: add show_first option to consolidate (#7702) (#7703)
Add optional show_first flag to consolidate directive that logs
the first error immediately and then consolidates subsequent errors.

When show_first is enabled:
- The first matching error is logged immediately with full details
  (rcode, domain, type, error message) using the configured log level
- Subsequent matching errors are consolidated during the period
- At period end:
  - If only one error occurred, no summary is printed (already logged)
  - If multiple errors occurred, summary shows the total count

Syntax:
  consolidate DURATION REGEXP [LEVEL] [show_first]

Example with 3 errors:
  [WARNING] 2 example.org. A: read udp 10.0.0.1:53->8.8.8.8:53: i/o timeout
  [WARNING] 3 errors like '^read udp .* i/o timeout$' occurred in last 30s

Example with 1 error:
  [WARNING] 2 example.org. A: read udp 10.0.0.1:53->8.8.8.8:53: i/o timeout

Implementation details:
- Add showFirst bool to pattern struct
- Rename inc() to consolidateError(), return false for showFirst case
- Use function pointer in ServeDNS to unify log calls with proper level
- Simplify logPattern() with single condition (cnt > 1 || !showFirst)
- Refactor parseLogLevel() to parseOptionalParams() with map-based dispatch
- Validate parameter order: log level must come before show_first
- Update README.md with show_first documentation and examples
- Add comprehensive test cases for show_first functionality

Signed-off-by: cangming <cangming@cangming.app>
2025-12-09 18:15:49 -08:00
..
2025-09-10 13:08:27 -07:00
2025-09-10 13:08:27 -07:00
2025-09-10 13:08:27 -07:00
2025-09-12 14:43:56 -07:00
2025-09-01 18:05:15 -07:00
2020-11-05 15:02:07 +01:00
2025-09-10 13:08:27 -07:00
2025-09-21 08:17:35 -07:00
2024-03-07 14:24:38 -05:00
2019-08-24 18:14:25 +00:00
2018-07-19 16:23:06 +01:00
2020-09-24 18:14:41 +02:00