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;
}
if (dupes) {
fprintf(logfile, "%s: last error repeated %d times\n", last_type, dupes+1);
if (logfile!=stderr) {
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;
}
@ -103,17 +100,20 @@ check_dupe(const char * format, const char * type)
void
_log_warn(const char * format, ...)
{
int dupe = check_dupe(format, "WARNING");
fflush(stdout);
if (!logfile) logfile = stderr;
if (!check_dupe(format, "WARNING")) {
if (logfile!=stderr) {
va_list marker;
fputs("WARNING: ", logfile);
va_start(marker, format);
vfprintf(logfile, format, marker);
va_end(marker);
if (logfile!=stderr) {
}
if (!dupe) {
if (log_flags & LOG_CPWARNING) {
va_list marker;
fputs("WARNING: ", stderr);
va_start(marker, format);
vfprintf(stderr, format, marker);
@ -123,23 +123,26 @@ _log_warn(const char * format, ...)
log_flush();
}
}
}
}
void
_log_error(const char * format, ...)
{
int dupe = check_dupe(format, "ERROR");
fflush(stdout);
if (!logfile) logfile = stderr;
if (!check_dupe(format, "ERROR")) {
if (logfile!=stderr) {
va_list marker;
fputs("ERROR: ", logfile);
va_start(marker, format);
vfprintf(logfile, format, marker);
va_end(marker);
}
if (!dupe) {
if (logfile!=stderr) {
if (log_flags & LOG_CPERROR) {
va_list marker;
fputs("ERROR: ", stderr);
va_start(marker, format);
vfprintf(stderr, format, marker);