static void log__submit(const char *file, int line, const char *func, const struct log_config *config, const char *subs, unsigned int sev, const char *format, va_list args) { const char *prefix = NULL; FILE *out; long long sec, usec; if (log__omit(file, line, func, config, subs, sev)) return; if (log__file) out = log__file; else out = stderr; log__time(&sec, &usec); if (sev < LOG_SEV_NUM) prefix = log__sev2str[sev]; if (prefix) { if (subs) fprintf(out, "[%.4lld.%.6lld] %s: %s: ", sec, usec, prefix, subs); else fprintf(out, "[%.4lld.%.6lld] %s: ", sec, usec, prefix); } else { if (subs) fprintf(out, "[%.4lld.%.6lld] %s: ", sec, usec, subs); else fprintf(out, "[%.4lld.%.6lld] ", sec, usec); } vfprintf(out, format, args); if (sev == LOG_DEBUG) { if (!func) func = "<unknown>"; if (!file) file = "<unknown>"; if (line < 0) line = 0; fprintf(out, " (%s() in %s:%d)\n", func, file, line); } else { fprintf(out, "\n"); } }
static void log__submit(const char *file, int line, const char *func, const char *subs, unsigned int sev, const char *format, va_list args) { int saved_errno = errno; const char *prefix = NULL; FILE *out; long long sec, usec; out = stderr; log__time(&sec, &usec); if (sev < LOG_SEV_NUM && sev > log_max_sev) return; if (sev < LOG_SEV_NUM) prefix = log__sev2str[sev]; if (prefix) { if (subs) { if (log__have_time()) fprintf(out, "[%.4lld.%.6lld] %s: %s: ", sec, usec, prefix, subs); else fprintf(out, "%s: %s: ", prefix, subs); } else { if (log__have_time()) fprintf(out, "[%.4lld.%.6lld] %s: ", sec, usec, prefix); else fprintf(out, "%s: ", prefix); } } else { if (subs) { if (log__have_time()) fprintf(out, "[%.4lld.%.6lld] %s: ", sec, usec, subs); else fprintf(out, "%s: ", subs); } else { if (log__have_time()) fprintf(out, "[%.4lld.%.6lld] ", sec, usec); } } errno = saved_errno; vfprintf(out, format, args); if (sev == LOG_DEBUG || sev <= LOG_WARNING) { if (!func) func = "<unknown>"; if (!file) file = "<unknown>"; if (line < 0) line = 0; fprintf(out, " (%s() in %s:%d)\n", func, file, line); } else { fprintf(out, "\n"); } }