From 6b251f7dd7cc89208813653124858d51f427e45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Thu, 9 Jan 2014 17:11:35 +0200 Subject: [PATCH] Log|libdeng2: Elaborate when a log entry throws an exception The format string is included in the error message. --- doomsday/libdeng2/include/de/core/log.h | 2 ++ doomsday/libdeng2/src/core/logbuffer.cpp | 24 +++++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doomsday/libdeng2/include/de/core/log.h b/doomsday/libdeng2/include/de/core/log.h index 4e48ef44f6..d8ed93b7e0 100644 --- a/doomsday/libdeng2/include/de/core/log.h +++ b/doomsday/libdeng2/include/de/core/log.h @@ -580,6 +580,8 @@ class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable /// Returns the number of sub-sections in the entry's section part. int sectionDepth() const { return _sectionDepth; } + String const &format() const { return _format; } + /** * Converts the log entry to a string. * diff --git a/doomsday/libdeng2/src/core/logbuffer.cpp b/doomsday/libdeng2/src/core/logbuffer.cpp index c74fc62246..acab710a15 100644 --- a/doomsday/libdeng2/src/core/logbuffer.cpp +++ b/doomsday/libdeng2/src/core/logbuffer.cpp @@ -273,28 +273,26 @@ void LogBuffer::flush() if(!d->toBeFlushed.isEmpty()) { - try + DENG2_FOR_EACH(Instance::EntryList, i, d->toBeFlushed) { - DENG2_FOR_EACH(Instance::EntryList, i, d->toBeFlushed) + DENG2_GUARD_FOR(**i, guardingCurrentLogEntry); + foreach(LogSink *sink, d->sinks) { - DENG2_GUARD_FOR(**i, guardingCurrentLogEntry); - - foreach(LogSink *sink, d->sinks) + if(sink->willAccept(**i)) { - if(sink->willAccept(**i)) + try { *sink << **i; } + catch(Error const &error) + { + *sink << String("Exception during log flush:\n") + + error.what() + "\n(the entry format is: '" + + (*i)->format() + "')"; + } } } } - catch(Error const &error) - { - foreach(LogSink *sink, d->sinks) - { - *sink << "Exception during log flush:\n" << error.what(); - } - } d->toBeFlushed.clear();