#include "tlsproxy.h"
#include "log.h"
-/* va_*() */
-#include <stdarg.h>
-/* pthread_self() */
#include <pthread.h>
+#include <stdarg.h>
void log_message(int level, const char *file, int line, const char *format, ...) {
(void)line;
#endif
- va_start(ap, format);
+ /* Prevent another thread from interrupting the two printfs(). */
+ flockfile(stdout);
+
fprintf(stdout,
#ifdef DEBUG
"%-12s:%-3d "
file, line,
#endif
level_string, (int)pthread_self());
+ va_start(ap, format);
vfprintf(stdout, format, ap);
- fprintf(stdout, "\n");
va_end(ap);
+ fprintf(stdout, "\n");
+
+ funlockfile(stdout);
}