forked from github/server
log_* routines write complete log to logfile, abbreviated (last message...) only to stderr.
This commit is contained in:
parent
fc70d1d66a
commit
64ca5c666e
|
@ -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 (log_flags & LOG_CPERROR) {
|
||||||
if (logfile!=stderr) {
|
fprintf(stderr, "%s: last message repeated %d times\n", last_type, dupes+1);
|
||||||
if (log_flags & LOG_CPERROR) {
|
|
||||||
fprintf(stderr, "%s: last error repeated %d times\n", last_type, dupes+1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dupes = 0;
|
dupes = 0;
|
||||||
}
|
}
|
||||||
|
@ -103,25 +100,27 @@ 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 (log_flags & LOG_CPWARNING) {
|
if (!dupe) {
|
||||||
fputs("WARNING: ", stderr);
|
if (log_flags & LOG_CPWARNING) {
|
||||||
va_start(marker, format);
|
va_list marker;
|
||||||
vfprintf(stderr, format, marker);
|
fputs("WARNING: ", stderr);
|
||||||
va_end(marker);
|
va_start(marker, format);
|
||||||
}
|
vfprintf(stderr, format, marker);
|
||||||
if (log_flags & LOG_FLUSH) {
|
va_end(marker);
|
||||||
log_flush();
|
}
|
||||||
}
|
if (log_flags & LOG_FLUSH) {
|
||||||
|
log_flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,17 +128,21 @@ _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);
|
||||||
|
|
Loading…
Reference in New Issue