void log_info(const char *format, ...) { const char * prefix = "INFO"; const int mask = LOG_CPINFO; /* write to the logfile, always */ if (logfile && (log_flags & mask)) { va_list args; va_start(args, format); _log_write(logfile, 0, prefix, format, args); va_end(args); } /* write to stderr, if that's not the logfile already */ if (logfile!=stderr && (log_stderr & mask)) { int dupe = check_dupe(format, prefix); if (!dupe) { va_list args; va_start(args, format); _log_write(stderr, stdio_codepage, prefix, format, args); va_end(args); } } if (log_flags & LOG_FLUSH) { log_flush(); } }
void log_printf(FILE * io, const char *format, ...) { const char * prefix = "INFO"; const int mask = LOG_CPINFO; /* write to the logfile, always */ if (logfile && (log_flags & mask)) { int codepage = (logfile==stderr || logfile==stdout) ? stdio_codepage : 0; va_list args; va_start(args, format); _log_write(logfile, codepage, prefix, format, args); va_end(args); } /* write to io, if that's not the logfile already */ if (logfile!=io && (log_stderr & mask)) { int dupe = check_dupe(format, prefix); if (!dupe) { va_list args; va_start(args, format); _log_write(io, stdio_codepage, prefix, format, args); va_end(args); } } if (log_flags & LOG_FLUSH) { log_flush(); } }
static void log_write(int flags, const char *module, const char *format, va_list args) { log_t *lg; for (lg = loggers; lg; lg = lg->next) { int level = flags & LOG_LEVELS; if (lg->flags & level) { int dupe = 0; if (lg->flags & LOG_BRIEF) { dupe = check_dupe(format, level); } if (dupe == 0) { vlog(lg, level, format, args); } } } }