Skip to content

Add support for channel-scoped logging & filtering - #1449

Open
snafudev wants to merge 6 commits into
omf2097:masterfrom
snafudev:logging-channels
Open

snafudev wants to merge 6 commits into
omf2097:masterfrom
snafudev:logging-channels

Conversation

@snafudev

@snafudev snafudev commented Sep 28, 2026 •

Copy link
Copy Markdown

Description:

Adds the ability to define a channel when calling log_debug / log_error etc.

You can then run the binary with '--log-channels' flag to only show log messages from the specified channels.

This will come in useful in the ai controller rework as we need the ability to either manually run a demo or record a demo while filtering out all the other noise unrelated to ai state/decision flow.

Changes:

  • introduce channels for ai, rec, network, video, audio tc
  • add CLI support for selecting enabled channels via --log-channels flag + document channel flag usage in README
  • add test coverage for the logging module behavior and channel parsing

Comment thread src/utils/log.h
Comment thread src/utils/log.h Outdated
Comment thread src/utils/log.c Outdated
Comment thread src/utils/log.c Outdated
Comment thread src/utils/log.c
@Vagabond

Copy link
Copy Markdown
Member

@snafudev did you switch away from using @Snafulator ? Did I invite the wrong github account?

@snafudev

Copy link
Copy Markdown
Author

@snafudev did you switch away from using @Snafulator ? Did I invite the wrong github account?

Didn't realise i had a second github account. That's embarassing lol.

@snafudev
snafudev force-pushed the logging-channels branch 5 times, most recently from 88d1dea to 69915f6 Compare September 29, 2026 04:04
Comment thread src/controller/rec_controller.c Outdated
Comment thread testing/misc/log_tests.c
Comment thread src/utils/log.c Outdated
Comment thread src/utils/log.c
@katajakasa

katajakasa commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Added one more comment about the channel bitmap, but imo otherwise this is good. Just make sure the CI passes.

@Snafulator

Copy link
Copy Markdown
Contributor

@snafudev did you switch away from using @Snafulator ? Did I invite the wrong github account?

Managed to recover my old account :)

- introduce channel bitmasks for AI state, AI decision, and REC logging
- add CLI support for selecting enabled channels via --log-channels + document log channel usage in README
- apply ai-state/ai-decisions channels to debug logging in ai_controller + remove unused debug logs (will be replaced in pilot-ai-v2)
- add test coverage for the logging module behavior and channel parsing
- restore printf-style attributes on log declarations
- add placeholder channels for network, gameplay, graphics, and sound
- update README and CLI docs to describe comma-separated channel filtering
- remove composite ai alias in favor of explicit per-channel selection
- clarify channel tagging vs. filter behavior in logging implementation
- Rename log_*_c to log_*_channel (to avoid confusion with C-string suffix conventions)
- Rename log_module_test to log_tests
- Rename graphics/sound log channels to video/audio (to match the directories)
Comment thread src/utils/log.c Outdated
@Snafulator

Copy link
Copy Markdown
Contributor

Added one more comment about the channel bitmap, but imo otherwise this is good. Just make sure the CI passes.

I don't use my non-work github accounts often, so i lost track of which one i was using for this project.

Will return to using Snafulator going forward.

Comment thread src/utils/log.c
}
// Untagged DEBUG messages stay quiet; untagged INFO/WARN/ERROR remain visible.
// When filtering, emit tagged messages only for the enabled channels.
if(module == LOG_CHANNEL_NONE) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit odd quirk, but I guess it is fine for now. Better solution though would be to allow more complex logging configs, e.g. via a config file ;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, it would be nice to not do magic like this -- it will bite someone in the ass sooner or later.

Comment thread src/utils/path.c
@@ -120,12 +120,95 @@ const char *path_c(const path *path) {
#endif

bool path_resolve(path *p) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, what happens here ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why ?

Comment thread src/utils/log.c
}

static void log_vmsg_channel(log_channel module, log_level level, const char *fmt, va_list args)
ATTR_FORMAT_PRINTF(3, 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this declaration? isn't the function defined right after here?

Comment thread src/utils/log.c
@@ -206,6 +201,9 @@ static void format_timestamp(char *buffer, size_t len) {
buffer[len - 1] = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use '\0' for for terminal character, since that's the convention for strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants