- fprintf(stdout, "[%s] [%d] ", level_string, (int)pthread_self());
- vfprintf(stdout, format, ap);
- fprintf(stdout, "\n");
+
+ /* Prevent another thread from interrupting the printfs(). */
+ flockfile(stderr);
+
+#ifdef DEBUG
+ fprintf(stderr, "%-12s:%-3d ", file, line);
+#endif
+ fprintf(stderr, "[%s] [%d] ", level_string, (int)pthread_self());
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);