Skip to content

Conversation

@a-turko
Copy link

@a-turko a-turko commented Jul 6, 2023

Enable users to decide for what kinds of log messages their log callbacks will be called. This filtering happens in the library in
order to avoid the malloc call in log__printf (logging_mosq.c) for messages that would be ignored anyway.

By default, no messages are filtered out. The set of allowed log types can be configured by mosquitto_log_levels_set.

Also, this pull request adds a unit test of this feature.

Note:
Two tests failed locally: 06-bridge-clean-session-csF-lcsT.py and c/03-publish-c2b-qos2-maximum-qos-1.test, but those were already failing before these changes.

a-turko added 2 commits July 6, 2023 12:24
Enable the users to decide for what kinds of log messages their log
callbacks will be called. This filtering happens in the library in
order to avoid the malloc call in log__printf (logging_mosq.c) for
messages that would be ignored anyway.
By default, no messages are filtered out. The set of allowed log types
can be configured by mosquitto_log_levels_set.

Note: Two additional log level masks (WARNING_AND_ABOVE and
      NOTICE_AND_ABOVE) have been added as shortcuts for
      convenience.

Signed-off-by: Andrzej Turko <[email protected]>
@a-turko a-turko changed the title Develop -- log filtering Enable log filtering Jul 6, 2023
@a-turko
Copy link
Author

a-turko commented Jul 19, 2023

Is there something wrong with this PR? Should I have included the requirement checklist in the message?
Is there anything else I could do to get the approval for the workflows?

@a-turko
Copy link
Author

a-turko commented Jul 24, 2023

@ralight, what do you think about this change?

Is there something wrong with this PR? Should I have included the requirement checklist in the message? Is there anything else I could do to get the approval for the workflows?

@moncefmechri
Copy link

@ralight is there anything blocking this PR from being considered?

@ralight ralight force-pushed the develop branch 3 times, most recently from 028adb2 to 604b69a Compare March 26, 2024 12:43
@ralight ralight force-pushed the develop branch 3 times, most recently from b7e2d3d to e715b04 Compare October 29, 2024 10:40
@ralight ralight force-pushed the develop branch 2 times, most recently from ae502fb to 9b6f004 Compare July 20, 2025 22:51
@ralight ralight force-pushed the develop branch 4 times, most recently from b612b85 to 93557bf Compare August 22, 2025 22:17
@bgianfo
Copy link

bgianfo commented Aug 29, 2025

I just was reading the code and realized this was an issue. This feature would be awesome if we could get it merged into the next release. Avoiding these extra allocations would be a great improvement.

Comment on lines +87 to +88
#define MOSQ_LOG_WARNING_AND_ABOVE (MOSQ_LOG_WARNING | MOSQ_LOG_ERR)
#define MOSQ_LOG_NOTICE_AND_ABOVE (MOSQ_LOG_WARNING_AND_ABOVE | MOSQ_LOG_NOTICE)
Copy link

Choose a reason for hiding this comment

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

nitpick: Are these really necessary? A user can create these masks themselves.

@a-turko
Copy link
Author

a-turko commented Sep 18, 2025

I just was reading the code and realized this was an issue. This feature would be awesome if we could get it merged into the next release. Avoiding these extra allocations would be a great improvement.

Thank you. However, so far this PR has not been getting any attention from the maintainers, so for now I'm going to hold off with making changes.

@ralight ralight force-pushed the develop branch 2 times, most recently from 6b404a7 to 2c4967a Compare October 10, 2025 22:17
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.

3 participants