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

log: add ML_ERR, ML_INFO, ML_DBG macros #250

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ extern void metal_default_log_handler(enum metal_log_level level,
? (void)_metal.common.log_handler(level, __VA_ARGS__) \
: (void)0)

/**
* Convenience macros ML_ERR, ML_INFO, ML_DBG add source
* function name and the line number before the message.
* Inspired by pr_err, pr_info, etc. in the kernel's printk.h.
*/
#define ML_ERR(fmt, args ...) metal_log(METAL_LOG_ERROR, "%s():%u "fmt, \
__func__, __LINE__, ##args)
#define ML_INFO(fmt, args ...) metal_log(METAL_LOG_INFO, "%s():%u "fmt, \
__func__, __LINE__, ##args)
#define ML_DBG(fmt, args ...) metal_log(METAL_LOG_DEBUG, "%s():%u "fmt, \
__func__, __LINE__, ##args)

/** @} */

#ifdef __cplusplus
Expand Down