C99 compatible version
This commit is contained in:
parent
774d7dad28
commit
4c835465ca
@ -24,6 +24,7 @@ int main(int argc, char** argv) {
|
||||
log_add_fp(f5, LOG_ERROR);
|
||||
log_add_fp(f6, LOG_FATAL);
|
||||
|
||||
/* C89-compatible usage example */
|
||||
log_trace2("TRACE - Hello %s", "world");
|
||||
log_debug2("DEBUG - Hello %s", "world");
|
||||
log_info2("INFO - Hello %s", "world");
|
||||
@ -31,9 +32,7 @@ int main(int argc, char** argv) {
|
||||
log_error2("ERROR - Hello %s", "world");
|
||||
log_fatal2("FATAL - Hello %s", "world");
|
||||
|
||||
/* Pre-C99 usage example
|
||||
log_trace3("test 3 args: %s %s", "arg1", "arg2");
|
||||
*/
|
||||
log_log(LOG_ERROR, __FILE__, __LINE__, "test 3 args: %s %s", "arg1", "arg2");
|
||||
|
||||
fclose(f1);
|
||||
|
19
src/log.h
19
src/log.h
@ -93,6 +93,25 @@ typedef void (*log_LockFn)(bool lock, void *udata);
|
||||
#define log_fatal5(arg1, arg2, arg3, arg4, arg5) log_internal5(LOG_FATAL, __FILE__, __LINE__, arg1, arg2, arg3, arg4, arg5);
|
||||
/* Pre-C99 compatible definitions - END */
|
||||
|
||||
|
||||
#define log_trace(...) \
|
||||
log_log(LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__);
|
||||
|
||||
#define log_debug(...) \
|
||||
log_log(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__);
|
||||
|
||||
#define log_info(...) \
|
||||
log_log(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__);
|
||||
|
||||
#define log_warn(...) \
|
||||
log_log(LOG_WARN, __FILE__, __LINE__, __VA_ARGS__);
|
||||
|
||||
#define log_error(...) \
|
||||
log_log(LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__);
|
||||
|
||||
#define log_fatal(...) \
|
||||
log_log(LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__);
|
||||
|
||||
const char *log_level_string(int level);
|
||||
void log_set_lock(log_LockFn fn, void *udata);
|
||||
void log_set_level(int level);
|
||||
|
Loading…
Reference in New Issue
Block a user