Main Page   Class Hierarchy   Compound List   File List   Compound Members  

GeneratorTrace.hpp

00001 /*
00002  *  This program is free software; you can redistribute it and/or modify
00003  *  it under the terms of the GNU General Public License as published by
00004  *  the Free Software Foundation; either version 2 of the License, or
00005  *  (at your option) any later version.
00006  *
00007  *  This program is distributed in the hope that it will be useful,
00008  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  *  GNU General Public License for more details.
00011  *
00012  *  You should have received a copy of the GNU General Public License
00013  *  along with this program; if not, write to the Free Software
00014  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015  *
00016  * (c)Copyright 2006 Hewlett-Packard Development Company, LP.
00017  *
00018  */
00019 
00020 #ifndef _GENERATORTRACE_H
00021 #define _GENERATORTRACE_H
00022 
00023 #include "iostream_t.hpp"
00024 #include "fstream_t.hpp"
00025 #include <cstring>
00026 #include "string_t.hpp"
00027 #include <cstdlib> // for exit definition
00028 
00029 #ifdef DEBUG_MODE
00030 #define GEN_DEBUG(l,m)  iostream_error << m << iostream_flush << iostream_endl
00031 #else
00032 #define GEN_DEBUG(l,m)
00033 #endif
00034 
00035 typedef enum _log_level {
00036  LOG_LEVEL_NO,
00037  LOG_LEVEL_ERR,
00038  LOG_LEVEL_WAR,
00039  LOG_LEVEL_MSG,
00040  LOG_LEVEL_BUF,
00041  LOG_LEVEL_TRAFFIC_ERR,
00042  LOG_LEVEL_ALL
00043 } T_LogLevel ;
00044 
00045 extern char *gen_log_header;
00046 
00047 extern const unsigned int gen_mask_table [] ;
00048 extern const char         gen_mask_char_table [] ;
00049 
00050 extern  void init_trace (unsigned int P_level, 
00051                          char        *P_fileName,
00052                          bool         P_useTime);
00053 
00054 extern  void init_trace (unsigned int  P_level, 
00055                          string_t&  P_fileName,
00056                          bool          P_useTime) ;
00057 
00058 
00059 extern  void close_trace       () ;
00060 extern  void no_time_func      (iostream_output*) ;
00061 extern  void current_time_func (iostream_output*) ;
00062 extern  void no_end_func       (void*);
00063 
00064 typedef void (*T_TimeFunc) (iostream_output*) ;
00065 typedef void (*T_TraceEndProc) (void *) ;
00066 
00067 extern  void use_trace_end (T_TraceEndProc P_proc, void* P_arg) ;
00068 
00069 extern  iostream_output *genTrace ;
00070 extern  unsigned int     genTraceLevel ;
00071 extern  T_TimeFunc       genTimeFunction ;
00072 extern  T_TraceEndProc   genTraceEndFunction ;
00073 extern  void            *genTraceEndArg ;
00074 
00075 // l: level, m: message (char*), c: exit code
00076 
00077 #define GEN_HEADER_LOG      gen_log_header
00078 #define GEN_HEADER_LEVEL(l) "|" << gen_mask_char_table[l] << "|"
00079 #define GEN_HEADER_NO_LEVEL "| |"
00080 
00081 #define GEN_FATAL(c,m)  \
00082              (*genTraceEndFunction)(genTraceEndArg); \
00083              *genTrace << "Fatal: " m << iostream_endl << iostream_flush ; \
00084              if (genTrace != &iostream_error) { \
00085                iostream_error << "Fatal: " m << iostream_endl << iostream_flush ; \
00086              } \
00087              exit ((c))
00088 
00089 #define GEN_WARNING(m)  if (genTraceLevel & gen_mask_table[LOG_LEVEL_WAR]) {\
00090              (*genTimeFunction)(genTrace) ; \
00091              *genTrace << "|" << gen_mask_char_table[LOG_LEVEL_WAR] \
00092                        << "|" << m << iostream_endl << iostream_flush  ; }
00093 
00094 #define GEN_ERROR(l,m)  if (genTraceLevel & gen_mask_table[LOG_LEVEL_ERR]) {\
00095              (*genTimeFunction)(genTrace) ; \
00096              *genTrace << "|" << gen_mask_char_table[LOG_LEVEL_ERR] \
00097                        <<"|" << m << iostream_endl << iostream_flush  ; }
00098 
00099 #define GEN_LOG_EVENT(l,m)  if (gen_mask_table[l] & genTraceLevel) {\
00100              (*genTimeFunction)(genTrace) ; \
00101              *genTrace << "|" << gen_mask_char_table[l] \
00102                        <<"|" << m << iostream_endl << iostream_flush  ; }
00103 #define GEN_LOG_EVENT_NO_DATE(l,m)  if (gen_mask_table[l] & genTraceLevel) {\
00104              *genTrace << gen_log_header ; \
00105              *genTrace << "|" << gen_mask_char_table[l] \
00106                        <<"|" << m << iostream_endl << iostream_flush  ; }
00107 
00108 #define GEN_LOG_EVENT_CONDITIONAL(l,c,m)  if (gen_mask_table[l] & genTraceLevel) {\
00109              if (c) {\
00110                (*genTimeFunction)(genTrace) ; \
00111                *genTrace << "|" << gen_mask_char_table[l] \
00112                          << "|" << m << iostream_endl << iostream_flush  ; } \
00113              }
00114 
00115 
00116 #define GEN_LOG_EVENT_FORCE(m)  \
00117              (*genTimeFunction)(genTrace) ; \
00118              *genTrace << "|" << gen_mask_char_table[LOG_LEVEL_ALL] \
00119                        << "|" << m << iostream_endl << iostream_flush 
00120 
00121 #endif // _GENERATORTRACE_H

Generated on Wed Mar 7 14:44:59 2007 for Seagull by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002