00001
00002
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00028 #include <exotkTrace.hxx>
00029 #ifndef _exotkTrace_Root_HeaderFile
00030 #include <exotkTrace_Root.hxx>
00031 #endif
00032 #ifndef _exotkTrace_Level_HeaderFile
00033 #include <exotkTrace_Level.hxx>
00034 #endif
00035 #ifndef _TCollection_AsciiString_HeaderFile
00036 #include <TCollection_AsciiString.hxx>
00037 #endif
00038 #include <stdarg.h>
00039 #include <stdio.h>
00040
00046 namespace exotkTrace_Datas
00047 {
00049 Handle_exotkTrace_Root theRoot;
00050 };
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 void exotkTrace::SetLevel(const enum exotkTrace_Level aLevel)
00062 {
00063 if ( !exotkTrace_Datas::theRoot.IsNull() )
00064 {
00065 exotkTrace_Datas::theRoot->SetLevel(aLevel);
00066 }
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076 exotkTrace_Level exotkTrace::Level()
00077 {
00078 if ( exotkTrace_Datas::theRoot.IsNull() )
00079 return exotkTrace_Unknown;
00080 else
00081 return exotkTrace_Datas::theRoot->Level();
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 void exotkTrace::SetHandler(const Handle_exotkTrace_Root& anHandler)
00093 {
00094 exotkTrace_Datas::theRoot = anHandler;
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104 Handle_exotkTrace_Root exotkTrace::Handler()
00105 {
00106 return exotkTrace_Datas::theRoot;
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 TCollection_AsciiString exotkTrace::TraceLevelToAsciiString(const enum exotkTrace_Level aLevel)
00119 {
00120 TCollection_AsciiString theString;
00121 switch ( aLevel )
00122 {
00123 case exotkTrace_Quiet:
00124 theString = TCollection_AsciiString("[ quiet ]");
00125 break;
00126 case exotkTrace_Error:
00127 theString = TCollection_AsciiString("[ error ]");
00128 break;
00129 case exotkTrace_Warning:
00130 theString = TCollection_AsciiString("[warning]");
00131 break;
00132 case exotkTrace_Info:
00133 theString = TCollection_AsciiString("[ info ]");
00134 break;
00135 case exotkTrace_Verbose:
00136 theString = TCollection_AsciiString("[verbose]");
00137 break;
00138 case exotkTrace_Debug:
00139 theString = TCollection_AsciiString("[ debug ]");
00140 break;
00141 default:
00142 break;
00143 }
00144 return theString;
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 void exotkTrace::Debug(char* aFormat,...)
00158 {
00159 if ( !exotkTrace_Datas::theRoot.IsNull() )
00160 {
00161 char Line[2048];
00162 va_list ArgPtr;
00163
00164 va_start(ArgPtr, aFormat);
00165
00166 vsprintf(Line, aFormat, ArgPtr);
00167 va_end(ArgPtr);
00168 exotkTrace_Datas::theRoot->Debug(Line);
00169 }
00170 }
00171 void exotkTrace::Verbose(char* aFormat,...)
00172 {
00173 if ( !exotkTrace_Datas::theRoot.IsNull() )
00174 {
00175 char Line[2048];
00176 va_list ArgPtr;
00177
00178 va_start(ArgPtr, aFormat);
00179
00180 vsprintf(Line, aFormat, ArgPtr);
00181 va_end(ArgPtr);
00182 exotkTrace_Datas::theRoot->Verbose(Line);
00183 }
00184 }
00185 void exotkTrace::Error(char* aFormat,...)
00186 {
00187 if ( !exotkTrace_Datas::theRoot.IsNull() )
00188 {
00189 char Line[2048];
00190 va_list ArgPtr;
00191
00192 va_start(ArgPtr, aFormat);
00193
00194 vsprintf(Line, aFormat, ArgPtr);
00195 va_end(ArgPtr);
00196 exotkTrace_Datas::theRoot->Error(Line);
00197 }
00198 }
00199 void exotkTrace::Warning(char* aFormat,...)
00200 {
00201 if ( !exotkTrace_Datas::theRoot.IsNull() )
00202 {
00203 char Line[2048];
00204 va_list ArgPtr;
00205
00206 va_start(ArgPtr, aFormat);
00207
00208 vsprintf(Line, aFormat, ArgPtr);
00209 va_end(ArgPtr);
00210 exotkTrace_Datas::theRoot->Warning(Line);
00211 }
00212 }
00213 void exotkTrace::Quiet(char* aFormat,...)
00214 {
00215 if ( !exotkTrace_Datas::theRoot.IsNull() )
00216 {
00217 char Line[2048];
00218 va_list ArgPtr;
00219
00220 va_start(ArgPtr, aFormat);
00221
00222 vsprintf(Line, aFormat, ArgPtr);
00223 va_end(ArgPtr);
00224 exotkTrace_Datas::theRoot->Quiet(Line);
00225 }
00226 }
00227 void exotkTrace::Info(char* aFormat,...)
00228 {
00229 if ( !exotkTrace_Datas::theRoot.IsNull() )
00230 {
00231 char Line[2048];
00232 va_list ArgPtr;
00233
00234 va_start(ArgPtr, aFormat);
00235
00236 vsprintf(Line, aFormat, ArgPtr);
00237 va_end(ArgPtr);
00238 exotkTrace_Datas::theRoot->Info(Line);
00239 }
00240 }