log_* routines write complete log to logfile, abbreviated (last message...) only to stderr.

This commit is contained in:
Enno Rehling 2006-04-09 17:53:45 +00:00
parent fc70d1d66a
commit 64ca5c666e
1 changed files with 21 additions and 18 deletions

View File

@ -87,11 +87,8 @@ check_dupe(const char * format, const char * type)
return 1; return 1;
} }
if (dupes) { if (dupes) {
fprintf(logfile, "%s: last error repeated %d times\n", last_type, dupes+1);
if (logfile!=stderr) {
if (log_flags & LOG_CPERROR) { if (log_flags & LOG_CPERROR) {
fprintf(stderr, "%s: last error repeated %d times\n", last_type, dupes+1); fprintf(stderr, "%s: last message repeated %d times\n", last_type, dupes+1);
}
} }
dupes = 0; dupes = 0;
} }
@ -103,17 +100,20 @@ check_dupe(const char * format, const char * type)
void void
_log_warn(const char * format, ...) _log_warn(const char * format, ...)
{ {
int dupe = check_dupe(format, "WARNING");
fflush(stdout); fflush(stdout);
if (!logfile) logfile = stderr; if (!logfile) logfile = stderr;
if (logfile!=stderr) {
if (!check_dupe(format, "WARNING")) {
va_list marker; va_list marker;
fputs("WARNING: ", logfile); fputs("WARNING: ", logfile);
va_start(marker, format); va_start(marker, format);
vfprintf(logfile, format, marker); vfprintf(logfile, format, marker);
va_end(marker); va_end(marker);
if (logfile!=stderr) { }
if (!dupe) {
if (log_flags & LOG_CPWARNING) { if (log_flags & LOG_CPWARNING) {
va_list marker;
fputs("WARNING: ", stderr); fputs("WARNING: ", stderr);
va_start(marker, format); va_start(marker, format);
vfprintf(stderr, format, marker); vfprintf(stderr, format, marker);
@ -124,22 +124,25 @@ _log_warn(const char * format, ...)
} }
} }
} }
}
void void
_log_error(const char * format, ...) _log_error(const char * format, ...)
{ {
int dupe = check_dupe(format, "ERROR");
fflush(stdout); fflush(stdout);
if (!logfile) logfile = stderr; if (!logfile) logfile = stderr;
if (!check_dupe(format, "ERROR")) { if (logfile!=stderr) {
va_list marker; va_list marker;
fputs("ERROR: ", logfile); fputs("ERROR: ", logfile);
va_start(marker, format); va_start(marker, format);
vfprintf(logfile, format, marker); vfprintf(logfile, format, marker);
va_end(marker); va_end(marker);
}
if (!dupe) {
if (logfile!=stderr) { if (logfile!=stderr) {
if (log_flags & LOG_CPERROR) { if (log_flags & LOG_CPERROR) {
va_list marker;
fputs("ERROR: ", stderr); fputs("ERROR: ", stderr);
va_start(marker, format); va_start(marker, format);
vfprintf(stderr, format, marker); vfprintf(stderr, format, marker);