Skip to content

Commit

Permalink
Log|libdeng2: Elaborate when a log entry throws an exception
Browse files Browse the repository at this point in the history
The format string is included in the error message.
  • Loading branch information
skyjake committed Jan 9, 2014
1 parent 911a9e1 commit 6b251f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 2 additions & 0 deletions doomsday/libdeng2/include/de/core/log.h
Expand Up @@ -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.
*
Expand Down
24 changes: 11 additions & 13 deletions doomsday/libdeng2/src/core/logbuffer.cpp
Expand Up @@ -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();

Expand Down

0 comments on commit 6b251f7

Please sign in to comment.