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

refactor: Simplification of output debug messages #154

Merged
merged 1 commit into from
May 20, 2019

Conversation

marktwtn
Copy link
Collaborator

Close #153.

@marktwtn marktwtn requested review from jserv and wusyong May 13, 2019 11:00
@marktwtn marktwtn self-assigned this May 13, 2019
src/common.h Outdated
@@ -8,6 +8,12 @@
#define __DCURL_MINOR__ 1
#define __DCURL_PATCH__ 0

#if defined(ENABLE_DEBUG)
#define DPRINTF(...) printf(__VA_ARGS__)
Copy link
Member

Choose a reason for hiding this comment

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

Eventually, dprintf might be conjuncted with logging facilities such as something in entangle. I would expect there is no direct call to printf.

Copy link
Member

Choose a reason for hiding this comment

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

Lower-case dprintf is better than the opposite form DPRINTF.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Eventually, dprintf might be conjuncted with logging facilities such as something in entangle. I would expect there is no direct call to printf.

I guess it will be left to the future modification?

Copy link
Member

Choose a reason for hiding this comment

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

We can proceed at the moment since it could be involved in small chunks of changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I found the logging function of entangled: log_debug()

static inline void dprintf(...) {
#if defined(ENABLE_DEBUG)
    log_debug();
#endif
}

void log_debug() {
    // The current dcurl implementation would be printf()
    // In the future,
    // it might be integrated with other logging facilities like entangled
    printf(...);
}

Is this what you expected to see?

Copy link
Member

Choose a reason for hiding this comment

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

selftest programs inside Linux kernel tree come with a nice example for writing dprintf: https://github.com/torvalds/linux/blob/master/tools/testing/selftests/x86/pkey-helpers.h

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since dprintf() has been declared in stdio.h, I rename it to dbgprintf() instead.

@wusyong wusyong added this to the Azalea milestone May 14, 2019
@marktwtn marktwtn force-pushed the simplify-printing-debug-message branch from 2342bac to dc04719 Compare May 20, 2019 02:26
src/common.h Outdated Show resolved Hide resolved
@marktwtn marktwtn force-pushed the simplify-printing-debug-message branch from dc04719 to 4f0c94d Compare May 20, 2019 02:44
@jserv jserv merged commit 8e2038b into DLTcollab:develop May 20, 2019
@marktwtn marktwtn deleted the simplify-printing-debug-message branch May 20, 2019 02:47
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.

Introduce macro for printing the debug messages
3 participants