1 #ifndef NOTIFY_H_V4O5JY61
2 #define NOTIFY_H_V4O5JY61
4 /* simple common notify hook */
6 typedef void (notify_fn_t
)(unsigned int, const char *, ...);
7 extern notify_fn_t
*notify
__attribute__((format(printf
, 2, 3)));
9 #define NOTIFY_LEVEL_FATAL 0
10 #define NOTIFY_LEVEL_ERROR 1
11 #define NOTIFY_LEVEL_INFO 2
12 #define NOTIFY_LEVEL_VERBOSE 3
13 #define NOTIFY_LEVEL_DEBUG 4
14 #define NOTIFY_LEVEL_LOCK 5
16 #define NOTIFY(__level__,__fmt__,...) do { if (notify) notify((__level__), __fmt__, ## __VA_ARGS__); } while (0)
17 #define NOTIFY_FATAL(fmt,...) NOTIFY(NOTIFY_LEVEL_FATAL, "@%s:%d/%s/" fmt "\n", __FILE__, __LINE__, __func__, ## __VA_ARGS__)
18 #define NOTIFY_ERROR(fmt,...) NOTIFY(NOTIFY_LEVEL_ERROR, "@%s:%d/%s/" fmt "\n", __FILE__, __LINE__, __func__, ## __VA_ARGS__)
19 #define NOTIFY_INFO(fmt,...) NOTIFY(NOTIFY_LEVEL_INFO, "@%s:%d/%s/" fmt "\n", __FILE__, __LINE__, __func__, ## __VA_ARGS__)
20 #define NOTIFY_VERBOSE(fmt,...) NOTIFY(NOTIFY_LEVEL_VERBOSE, "@%s:%d/%s/" fmt "\n", __FILE__, __LINE__, __func__, ## __VA_ARGS__)
22 #define NOTIFY_DEBUG(fmt,...) NOTIFY(NOTIFY_LEVEL_DEBUG, "@%s:%d/%s/" fmt "\n", __FILE__, __LINE__, __func__, ## __VA_ARGS__)
23 #define NOTIFY_DEBUG_LOCK(fmt,...) NOTIFY((NOTIFY_LEVEL_LOCK), "@%s:%d/%s/" fmt "\n", __FILE__, __LINE__, __func__, ## __VA_ARGS__)
25 #define NOTIFY_DEBUG(fmt,...) do { } while (0)
26 #define NOTIFY_DEBUG_LOCK(fmt,...) do { } while (0)
29 #endif /* NOTIFY_H_V4O5JY61 */