77#include <stdlib.h>
88#include <stdint.h>
99#include <stdbool.h>
10+ #include <errno.h>
1011#include <inttypes.h>
1112
1213/* Defitition */
1617
1718/* Macro */
1819
19- #define pr_error ( format , arg ...) \
20- fprintf(stderr, format, ##arg)
20+ #define prln_with_level ( level , format , arg ...) \
21+ fprintf(stderr, "[%s@"__FILE__":%u] " #level ": " format "\n", __func__, __LINE__ , ##arg)
2122
22- #define pr_error_with_errno (format , arg ...) \
23- pr_error(format", errno: %d, error: %s\n", ##arg, errno, strerror(errno) )
23+ #define prln_fatal (format , arg ...) \
24+ prln_with_level(fatal, format, ##arg)
2425
25- #define pr_warn (format , arg ...) \
26- printf("%s:%d: "format, __FUNCTION__, __LINE__, ##arg)
26+ #define prln_error (format , arg ...) \
27+ prln_with_level(error, format, ##arg)
28+
29+ #define prln_warn (format , arg ...) \
30+ prln_with_level(warning, format, ##arg)
31+
32+ #define prln_info (format , arg ...) \
33+ prln_with_level(info, format, ##arg)
2734
2835#ifdef DEBUGGING
29- #define pr_debug (format , arg ...) \
30- printf("%s:%d( debug): "format, __FUNCTION__, __LINE__ , ##arg)
36+ #define prln_debug (format , arg ...) \
37+ prln_with_level( debug, format , ##arg)
3138#else
32- #define pr_debug (format , arg ...)
39+ #define prln_debug (format , arg ...)
3340#endif
3441
42+ #define prln_error_with_errno (format , arg ...) \
43+ prln_error(format", errno: %d, error: %s", ##arg, errno, strerror(errno))
44+
3545#endif
0 commit comments