Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging callback #201

Merged
merged 19 commits into from
Jan 16, 2025
Merged

Add logging callback #201

merged 19 commits into from
Jan 16, 2025

Conversation

KGronek-Pubnub
Copy link
Contributor

feat(log): add possibility to replace default log function with a callback provided by the user

#define PUBNUB_LOG_PRINTF(LVL, ...) \
do { \
if (pubnub_log_callback) { \
char logMessage[1024]; \
Copy link
Contributor

Choose a reason for hiding this comment

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

@KGronek-Pubnub Buffer size won't be an issue here?
Also, I'm concerned about change in signature because of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@parfeon yeah I was afraid that this change in signature could cause some potential issues :/ thanks
I will change this logic to happen in PUBNUB_LOG macro instead.
As for the buffer size, I can change to calculate it dynamically.

@KGronek-Pubnub KGronek-Pubnub changed the title All logging callback Add logging callback Jan 3, 2025
@KGronek-Pubnub KGronek-Pubnub added the status: done This issue is considered resolved. label Jan 9, 2025
#define PUBNUB_LOG(LVL, ...) \
do { \
if (LVL <= PUBNUB_LOG_LEVEL) { \
if (pubnub_log_callback) { \
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure that we want to have this dynamic decision making?
Shouldn't we make it a compilation flag?

I mean it makes sense when a flag would be set to TRUE (to check if somebody added the callback) but it makes a difference as it is called very frequently for our customers that doesn't need this feature.
Probably the performance loss won't be even noticed but I want to start the discussion about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

@KGronek-Pubnub @parfeon
What are your opinions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure I could rework it to be a flag instead, just I think there are already so many compilation flags, so for end users it might be very difficult to understand and compile the version they need.
I don't think validation check can make any performance loss, so it's more a design decision here.

Copy link
Contributor

Choose a reason for hiding this comment

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

C-core is mostly configurable via the compilation flags. It's not the best design but still I would stick to that concept.
But I won't block this PR if there are no other voices.

@Xavrax
Copy link
Contributor

Xavrax commented Jan 9, 2025

Anyway overall LGTM - just discuss and resolve the conversation.

Copy link
Contributor

@Xavrax Xavrax left a comment

Choose a reason for hiding this comment

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

LGTM

@KGronek-Pubnub
Copy link
Contributor Author

@pubnub-release-bot release

@KGronek-Pubnub KGronek-Pubnub merged commit 595409b into master Jan 16, 2025
5 checks passed
@KGronek-Pubnub KGronek-Pubnub deleted the CLEN-1962 branch January 16, 2025 08:35
@pubnub-release-bot
Copy link
Contributor

🚀 Release successfully completed 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: done This issue is considered resolved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants