/* The software in this package is distributed under the GNU General Public License version 2 (with a special exception described below). A copy of GNU General Public License (GPL) is included in this distribution, in the file COPYING.GPL. As a special exception, if other files instantiate templates or use macros or inline functions from this file, or you compile this file and link it with other works to produce a work based on this file, this file does not by itself cause the resulting work to be covered by the GNU General Public License. However the source code for this file must still be made available in accordance with section (3) of the GNU General Public License. This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ /** @file * @brief provides tracing funtionality. * * Provides a scope tracker * * @copyright © Copyright 2008 by Intra2net AG */ #ifndef __I2N_COMMON_TRACEFUNC_HPP__ #define __I2N_COMMON_TRACEFUNC_HPP__ #include #include "logfunc.hpp" #include "source_track_basics.hpp" namespace I2n { namespace Tracer { class PerThreadContainer; /** * @brief scope tracker class. * * basically: emits a ENTER message on construction and a LEAVE message on destruction. * And indent these messages acoording to the nesting depth. * * If something goes wrong nothing is thrown from constructor/destructor. Will try to * log only that some problem occurred. */ class ScopeTracker { public: ScopeTracker(const SourceLocation& loc) throw (); ~ScopeTracker() throw (); private: ScopeTracker(const ScopeTracker& rhs); ScopeTracker& operator = (const ScopeTracker& rhs); SourceLocation Location; int Depth; int FuncDepth; std::string Tag; // might be empty std::string &get_tag(); // returns Tag, creates it first if necessary PerThreadContainer *PerThread; }; // eo ScopeTracker /* ** helper macros: */ /** * @brief constructs a scope tracker. */ #define SCOPETRACKER() ::I2n::Tracer::ScopeTracker __scope_tracker(HERE) } // eo namespace Tracer } // eo namespace I2n #endif