* @param level the desired indent level.
*/
static void ensure_indent_level(PerThreadContainer *per_thread, unsigned int level)
+ throw(std::length_error, std::bad_alloc)
{
// First initialization?
if (per_thread->indents.empty())
* @param loc the source location.
*
* the message is indented according to the current depth of nested ScopeTracker instances.
+ *
+ * All exceptions happening in here (from vector::reserve, vector::push_back, acquiring lock for logger)
+ * are caught. Will try to log only that problem occurred
*/
ScopeTracker::ScopeTracker(
- const SourceLocation& loc)
+ const SourceLocation& loc) throw ()
: Location(loc)
, Depth(0)
, FuncDepth(0)
try_logging_error("Failed to get thread local storage");
return;
}
- if (!PerThread->scope_tracker_list.empty())
- {
- ScopeTracker* last_tracker= PerThread->scope_tracker_list.back();
- if (Location)
- {
- if (last_tracker->Location
- && last_tracker->Location.File == Location.File
- && last_tracker->Location.FunctionName == Location.FunctionName)
- {
- FuncDepth= last_tracker->FuncDepth+1;
- }
- }
- Depth= last_tracker->Depth + 1;
- }
- ensure_indent_level(PerThread, Depth);
- PerThread->scope_tracker_list.push_back(this);
- // spit a message
- if (Logger::has_log_level(Logger::LogLevel::Debug))
- {
- GlobalLogger.debug() << PerThread->indents[Depth] << "ENTER " << get_tag();
- }
-} // eo ScopeTrcaker::ScopeTracker(const SourceLocation&)
+ try
+ {
+ if (!PerThread->scope_tracker_list.empty())
+ {
+ ScopeTracker* last_tracker= PerThread->scope_tracker_list.back();
+ if (Location)
+ {
+ if (last_tracker->Location
+ && last_tracker->Location.File == Location.File
+ && last_tracker->Location.FunctionName == Location.FunctionName)
+ {
+ FuncDepth= last_tracker->FuncDepth+1;
+ }
+ }
+ Depth= last_tracker->Depth + 1;
+ }
+
+ ensure_indent_level(PerThread, Depth);
+ PerThread->scope_tracker_list.push_back(this);
+
+ // spit a message
+ if (Logger::has_log_level(Logger::LogLevel::Debug))
+ {
+ GlobalLogger.debug() << PerThread->indents[Depth] << "ENTER " << get_tag();
+ }
+ }
+ catch (...)
+ {
+ try_logging_error("Caught exception in constructor");
+ }
+} // eo ScopeTracker::ScopeTracker(const SourceLocation&)
/**
/**
* @brief destructor. emits a LEAVE message.
*
- *
+ * All exceptions are caught, will try to log only that some problem occurred
*/
-ScopeTracker::~ScopeTracker()
+ScopeTracker::~ScopeTracker() throw ()
{
if (PerThread == NULL)
{
try_logging_error("Failed to get thread local storage");
return;
}
- // spit a message
- if (Logger::has_log_level(Logger::LogLevel::Debug))
- {
- GlobalLogger.debug() << PerThread->indents[Depth] << "LEAVE " << get_tag();
- }
- if (PerThread->scope_tracker_list.empty())
- {
- return;
- }
- if (PerThread->scope_tracker_list.back() == this)
- {
- PerThread->scope_tracker_list.pop_back();
- }
- else
- {
- // oh hell, this should never be the case!
- //TODO
- GlobalLogger.error() << "inconsistency detected in scope tracker";
- }
+
+ try
+ {
+ // spit a message
+ if (Logger::has_log_level(Logger::LogLevel::Debug))
+ {
+ GlobalLogger.debug() << PerThread->indents[Depth] << "LEAVE " << get_tag();
+ }
+ if (PerThread->scope_tracker_list.empty())
+ {
+ return;
+ }
+ if (PerThread->scope_tracker_list.back() == this)
+ {
+ PerThread->scope_tracker_list.pop_back();
+ }
+ else
+ {
+ // oh hell, this should never be the case!
+ //TODO
+ GlobalLogger.error() << "inconsistency detected in scope tracker";
+ }
+ }
+ catch (...)
+ {
+ try_logging_error("Caught exception in destructor");
+ }
} // eo ScopeTracker::~ScopeTracker()