attempting fix of va_list bug
This commit is contained in:
parent
aa92d72541
commit
1d06030aec
1 changed files with 24 additions and 2 deletions
|
@ -33,6 +33,28 @@ void libp2p_logger_log(const char* area, int log_level, const char* format, ...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message to the console
|
||||||
|
* @param area the class it is coming from
|
||||||
|
* @param log_level logger level
|
||||||
|
* @param format the logging string
|
||||||
|
* @param ... params
|
||||||
|
*/
|
||||||
|
void libp2p_logger_vlog(const char* area, int log_level, const char* format, va_list argptr) {
|
||||||
|
if (log_level <= CURRENT_LOGLEVEL) {
|
||||||
|
int found = 0;
|
||||||
|
for (int i = 0; i < logger_classes_len; i++) {
|
||||||
|
if (strcmp(logger_classes[i], area) == 0) {
|
||||||
|
found = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
|
vfprintf(stderr, format, argptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a debug message to the console
|
* Log a debug message to the console
|
||||||
* @param area the class it is coming from
|
* @param area the class it is coming from
|
||||||
|
@ -42,7 +64,7 @@ void libp2p_logger_log(const char* area, int log_level, const char* format, ...)
|
||||||
void libp2p_logger_debug(const char* area, const char* format, ...) {
|
void libp2p_logger_debug(const char* area, const char* format, ...) {
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, format);
|
va_start(argptr, format);
|
||||||
libp2p_logger_log(area, LOGLEVEL_DEBUG, format, argptr);
|
libp2p_logger_vlog(area, LOGLEVEL_DEBUG, format, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +77,6 @@ void libp2p_logger_debug(const char* area, const char* format, ...) {
|
||||||
void libp2p_logger_error(const char* area, const char* format, ...) {
|
void libp2p_logger_error(const char* area, const char* format, ...) {
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, format);
|
va_start(argptr, format);
|
||||||
libp2p_logger_log(area, LOGLEVEL_ERROR, format, argptr);
|
libp2p_logger_vlog(area, LOGLEVEL_ERROR, format, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue