long long linenr, int flags, const char *fmt, ...) {
static bool logVersionStderr = true;
char *str = NULL;
- char *msg;
+ char *msg = NULL;
struct timeval cur_time;
struct tm time_info;
int len, fprio, i, ret;
int saved_errno = errno;
+ int emit = 1;
if (!virLogInitialized)
virLogStartup();
fprio = virLogFiltersCheck(category);
if (fprio == 0) {
if (priority < virLogDefaultPriority)
- goto cleanup;
+ emit = 0;
} else if (priority < fprio) {
- goto cleanup;
+ emit = 0;
}
/*
goto cleanup;
/*
- * Log based on defaults, first store in the history buffer
- * then push the message on the outputs defined, if none
+ * Log based on defaults, first store in the history buffer,
+ * then if emit push the message on the outputs defined, if none
* use stderr.
* NOTE: the locking is a single point of contention for multiple
* threads, but avoid intermixing. Maybe set up locks per output
*/
len = strlen(msg);
virLogStr(msg, len);
+ if (emit == 0)
+ goto cleanup;
+
virLogLock();
for (i = 0; i < virLogNbOutputs;i++) {
if (priority >= virLogOutputs[i].priority) {
}
virLogUnlock();
- VIR_FREE(msg);
cleanup:
+ VIR_FREE(msg);
errno = saved_errno;
}