Hello all,
I have asked for this before, I think, but it would be really nice if
output from the various clam binaries went to different file desriptors,
depending on whether they are errors, warnings, or informative. This
would more easily filtering of output in things like cron jobs and the
like. I believe the attached patch does so.
--- clamav-devel-latest/shared/output.c 2004-10-16 20:48:02.000000000 -0400
+++ output.c 2005-01-16 14:04:52.000000000 -0500
@@ -240,11 +240,6 @@
return;
}
- if(mprintf_stdout)
- fd = stdout;
- else
- fd = stderr;
-
/* legend:
* ! - error
* @ - error with logging
@@ -253,11 +248,13 @@
/*
* ERROR WARNING STANDARD
- * normal yes yes yes
+ * normal stderr stderr stdout
*
- * verbose yes yes yes
+ * verbose stderr stderr stdout
*
- * quiet yes no no
+ * quiet stderr no no
+ *
+ * (unless --stdout is passed)
*/
@@ -266,9 +263,17 @@
va_start(argscpy, str);
if(*str == '!') {
+ if(mprintf_stdout)
+ fd = stdout;
+ else
+ fd = stderr;
fprintf(fd, "ERROR: ");
vfprintf(fd, ++str, args);
} else if(*str == '@') {
+ if(mprintf_stdout)
+ fd = stdout;
+ else
+ fd = stderr;
fprintf(fd, "ERROR: ");
vfprintf(fd, ++str, args);
#ifdef NO_SNPRINTF
@@ -279,12 +284,20 @@
logg("ERROR: %s", logbuf);
} else if(!mprintf_quiet) {
if(*str == '^') {
+ if(mprintf_stdout)
+ fd = stdout;
+ else
+ fd = stderr;
fprintf(fd, "WARNING: ");
vfprintf(fd, ++str, args);
} else if(*str == '*') {
+ fd = stdout;
if(mprintf_verbose)
vfprintf(fd, ++str, args);
- } else vfprintf(fd, str, args);
+ } else {
+ fd = stdout;
+ vfprintf(fd, str, args);
+ }
}
va_end(args);
Thanks,
--
--------------------------------------------------------------------------
| Stephen Gran | Mr. Cole's Axiom: The sum of the |
| steve@lobefin.net | intelligence on the planet is a |
| http://www.lobefin.net/~steve | constant; the population is growing. |
--------------------------------------------------------------------------
_______________________________________________
http://lists.clamav.net/cgi-bin/mailman/listinfo/clamav-devel