
On 03/10/2014 09:01 AM, Daniel P. Berrange wrote:
The error reporting code will invoke a callback when any error is raised and the default callback will print to stderr. The virRaiseErrorFull method also sends all error messages on to the logging code, which also prints to stderr by default. To avoid duplicated data on stderr, the logging code has some logic to skip emission when no log outputs are configured, which checks whether the virLogSource == VIR_LOG_FROM_ERROR.
Meanwhile the libvirtd daemon can register another callback which is used to reduce log message priority from error to a lower level. When this is used we do want messages to end up on stderr, so the error code will conditionally use either VIR_LOG_FROM_FILE or VIR_LOG_FROM_ERROR depending on whether such a callback is provided.
This will all complicate later refactoring. By pushing the checks for whether a log output is present up a level into the error code, the special cases can be isolated in one place.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/util/virerror.c | 17 +++++++++++++---- src/util/virlog.c | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-)
ACK -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org