Skip to content

Conversation

@yoursanonymous
Copy link

##Description
This PR standardizes the logging mechanism in main.c by introducing structured macros and replacing raw printf calls with LOG_INFO or LOG_ERROR for consistency.

To improve log readability, allow for easier filtering of error vs. info messages, and simplify future logging extensions.

@joseph-yiu
Copy link
Contributor

A potential risk of this approach is macro name clash with other codes inside your project, especially when the project contains 3rd party codes. LOG_INFO and LOG_ERROR are commonly used and therefore it might be best to add prefix in the macro names.
Additionally, in large projects the macro definition might already present, so the usual practice is to do the define conditionally.
e.g.
#ifndef AUDIOMARK_LOG_INFO
#define AUDIOMARK_LOG_INFO(fmt, ...) printf("[INFO] " fmt "\n", ##VA_ARGS)
#endif
#ifndef AUDIOMARK_LOG_ERROR
#define AUDIOMARK_LOG_ERROR(fmt, ...) printf("[ERROR] " fmt "\n", ##VA_ARGS)
#endif

Thanks and regards,
Joseph

@yoursanonymous
Copy link
Author

Thanks for the suggestion, Joseph

I have updated the logging macros to use an AUDIOMARK_ prefix and wrapped the definitions with #ifndef guards to avoid name clashes with other code.

Thanks again for the helpful review.

Best regards,
Vinayak

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.

2 participants