Add support for negative logging categories in the log gateway - #508
Add support for negative logging categories in the log gateway#508ZayanKhan-12 wants to merge 1 commit into
Conversation
Categories prefixed with '!' in the logging_categories setting specify messages that should not be written to the error log. A negative match takes precedence over any positive match, and when only negative categories are specified, all other messages remain pertinent, so e.g. ["!access"] logs everything except access messages. Behaviour is unchanged when logging_categories is omitted (everything is logged), empty (nothing is logged), or contains only positive categories. Closes sony#338 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
garethsb
left a comment
There was a problem hiding this comment.
Nice, focused change that matches #338. I recommend a few small tweaks before merge.
1. Align example config comments
nmos-cpp-node/config.json and nmos-cpp-registry/config.json still only describe the include form. Please mirror the updated settings.h wording with one extra line on the ! prefix (and the “only excluded categories ⇒ everything else included” behaviour).
2. Treat "!" as negated ""
Today "!" is classified as negative (so it can enable “negation-only” mode) but the empty-categories path only looks for "", so "!" never excludes uncategorized messages and is effectively a no-op.
Suggestion: in the categories.empty() branch, if "!" is present return false (negative wins), else keep default_pertinent || has "". That makes the prefix rule complete and allows useful configs such as ["!"] (everything except uncategorized) and ["!", "!access"].
3. Extra test
Please add a case for ["access", "!access"] (negative wins over the same positive), and for "!" excluding uncategorized once (2) is in.
4. CI
There are no checks reported on this branch yet. @lo-simon please could you allow workflows to run?
Thanks also for the Catch/Boost notes for #506...
- I'm surprised about the need for
__aarch64__as I thought this has been built on Linux arm64 and that there was a current macOS runner 🤔 - we have bigger issues with recent Boost (since Asio deprecated API has been removed) but this sounds like an easy win in another PR
Closes #338
Implements the enhancement suggested in #338: categories prefixed with
!in thelogging_categoriessetting specify messages that should not be written to the error log.Semantics
send_query_ws_eventsandaccessis suppressed by["send_query_ws_events", "!access"].["!access"]means "everything except access", which makes the feature usable on its own.logging_categoriesis omitted (everything logged), explicitly empty (nothing logged), or contains only positive categories, including the empty-string entry that selects messages with no category.The settings schema already accepts these values (
stringArray), and thelogging_categoriescomment innmos/settings.his updated to document the prefix.Testing
New
nmos/test/log_gate_test.cppcovers all the cases above via a smalllog_gatesubclass (20 assertions). Full local run: all 169 test cases / 2361 assertions pass (macOS arm64, apple-clang, conan dependencies perconanfile.txt).Two environment notes from getting the suite running on an arm64 Mac, in case they're useful for #506:
third_party/catch/catch.hppneeds an__aarch64__branch forCATCH_TRAP()(int $3doesn't assemble on arm64) and an unsignedRandomNumberGenerator::result_typefor modern libc++ — happy to submit separately if of interest;Boost.Systemstub entirely, sofind_package(Boost COMPONENTS system ...)fails against current Boost — droppingsystemfromFIND_BOOST_COMPONENTSworks fine with 1.83+.🤖 Generated with Claude Code