UTCallLogger.h

Go to the documentation of this file.
00001 //==================================================================================================
00002 // Copyright (C) 2010  Brian Tietz    sdbtietz at yahoo dot com
00003 //
00004 // This program is free software; you can redistribute it and/or modify it under the terms of the
00005 // GNU General Public License as published by the Free Software Foundation, version 2.0 of the
00006 // License.
00007 //
00008 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
00009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00010 // General Public License for more details.
00011 //
00012 // You should have received a copy of the GNU General Public License along with this program; if
00013 // not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00014 // 02110-1301, USA.
00015 //
00016 // For commercial software, the copyright holder (Brian Tietz, email sdbtietz at yahoo dot com)
00017 // reserves the right and is willing to waive the proprietary source code disclosure aspects of that
00018 // license as applied to the UT library in exchange for either substantial contributions to the
00019 // development of the UT library or other forms of compensation.  Any such waiver must be
00020 // established in writing between the copyright holder and the commercial entity obtaining such a
00021 // waiver.
00022 //==================================================================================================
00023 
00024 
00025 #ifndef _UT_CALL_LOGGER_H_
00026 #define _UT_CALL_LOGGER_H_
00027 
00028 
00029 //==================================================================================================
00030 //=== Project headers
00031 //==================================================================================================
00032 #include "UTString.h"
00033 
00034 
00035 //==================================================================================================
00036 class UT_EXPORT CallLogger_t
00037 //==================================================================================================
00045 {
00046     //----------------------------------------------------------------------------------------------
00047     public:
00048     //----------------------------------------------------------------------------------------------
00049     inline      CallLogger_t(   bool include_caller_info,
00050                                 int skip_caller_frames = 0,
00051                                 bool show_timestamps_ms = false,
00052                                 int delay_ms_after_each_print = 0 );
00063 
00064     inline      ~CallLogger_t();
00068 
00069     void        EnterFunction( stringliteral* name, stringliteral* format, ...  );
00077 
00078     void        EnterFunctionV( stringliteral* name, stringliteral* format, va_list args );
00086 
00087     void        LogStatus( int line, const Status_t& status );
00089 
00090     void        LogStatus( int line, stringliteral* format, ... );
00093 
00094     void        LogStatusV( int line, stringliteral* format, va_list args );
00097 
00098     void        LogStatusStart( int line, stringliteral* format, ... );
00105 
00106     void        LogStatusStartV( int line, stringliteral* format, va_list args );
00113 
00114     void        LogStatusBuffer( const byte* buffer, int length, int max_end_lengths );
00121 
00122     void        LogStatusFinish( stringliteral* format, ... );
00126 
00127     void        LogStatusFinishV( stringliteral* format, va_list args );
00131 
00132     void        ExitFunction(int line);
00134 
00135     void        ExitFunction( int line, const Status_t& status );
00138 
00139     void        ExitFunction( int line, stringliteral* format, ... );
00142 
00143     void        ExitFunctionV( int line, stringliteral* format, va_list args );
00146 
00147     //----------------------------------------------------------------------------------------------
00148     private:
00149     //----------------------------------------------------------------------------------------------
00150     void                    SetPrefixAndIndent();
00151 
00152     //----------------------------------------------------------------------------------------------
00153     private:
00154     //----------------------------------------------------------------------------------------------
00155     bool                    m_include_caller_info;
00156     int                     m_skip_control_frames;
00157     int                     m_call_depth;
00158     bool                    m_show_timestamps;
00159     int                     m_delay_us_after_each_print;
00160     String_t                m_string;
00161 };
00162 
00163 
00164 
00165 
00166 //==================================================================================================
00167 //==================================================================================================
00168 //===
00169 //=== Inline function implementations
00170 //===
00171 //==================================================================================================
00172 //==================================================================================================
00173 inline
00174 CallLogger_t::CallLogger_t( bool include_caller_info,
00175                             int skip_caller_frames,
00176                             bool show_timestamps,
00177                             int delay_ms_after_each_print )
00178 {
00179     m_include_caller_info = include_caller_info;
00180     m_skip_control_frames = 2 + skip_caller_frames; // Call logger function and caller
00181     m_show_timestamps = show_timestamps;
00182     m_delay_us_after_each_print = delay_ms_after_each_print * 1000;
00183     m_call_depth = 0;
00184 }
00185 
00186 
00187 inline
00188 CallLogger_t::~CallLogger_t()
00189 {
00190     assert(m_call_depth == 0);
00191 }
00192 
00193 
00194 #endif // _UT_CALL_LOGGER_H_

Generated on Tue Dec 14 22:35:05 2010 for UT library by  doxygen 1.6.1