mirror of
https://github.com/upa/mscp.git
synced 2026-02-16 02:14:42 +08:00
add message.h and message.c, mscp_set|get_error()
Instead of pr_err(), libmscp uses mscp_set_error() and applications use mscp_get_errror() to get error message.
This commit is contained in:
32
src/message.h
Normal file
32
src/message.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _MESSAGE_H_
|
||||
#define _MESSAGE_H_
|
||||
|
||||
#include <libgen.h>
|
||||
|
||||
enum {
|
||||
MSCP_SEVERITY_ERR = 0,
|
||||
MSCP_SEVERITY_WARN,
|
||||
MSCP_SEVERITY_NOTICE,
|
||||
MSCP_SEVERITY_INFO,
|
||||
MSCP_SEVERITY_DEBUG,
|
||||
};
|
||||
|
||||
/* message print. printed messages are passed to application via msg_fd */
|
||||
//void mprint_set_severity(int severity);
|
||||
//void mprint(int severity, const char *fmt, ...);
|
||||
|
||||
#define mpr_err(fmt, ...) mprint(MSCP_SEVERITY_ERR, fmt, ##__VA_ARGS__)
|
||||
#define mpr_warn(fmt, ...) mprint(MSCP_SEVERITY_WARN, fmt, ##__VA_ARGS__)
|
||||
#define mpr_notice(fmt, ...) mprint(MSCP_SEVERITY_NOTICE, fmt, ##__VA_ARGS__)
|
||||
#define mpr_info(fmt, ...) mprint(MSCP_SEVERITY_INFO, fmt, ##__VA_ARGS__)
|
||||
#define mpr_debug(fmt, ...) mprint(MSCP_SEVERITY_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
/* error message buffer */
|
||||
#define mscp_set_error(fmt, ...) \
|
||||
_mscp_set_error("%s:%d:%s: " fmt, \
|
||||
basename(__FILE__), __LINE__, __func__, ##__VA_ARGS__)
|
||||
|
||||
void _mscp_set_error(const char *fmt, ...);
|
||||
|
||||
#endif /* _MESSAGE_H_ */
|
||||
Reference in New Issue
Block a user