logger_8c-source.html
来自「仿真人工智能是指用人工的方法和技术」· HTML 代码 · 共 243 行 · 第 1/2 页
HTML
243 行
00173 }00174 <a name="l00178"></a><a class="code" href="classLogger.html#a6">00178</a> <font class="keywordtype">int</font> <a class="code" href="classLogger.html#a6">Logger::getMinLogLevel</a>( )<font class="keyword"> const</font>00179 <font class="keyword"></font>{00180 <font class="keywordflow">return</font> <a class="code" href="classLogger.html#o2">iMinLogLevel</a>;00181 }00182 <a name="l00187"></a><a class="code" href="classLogger.html#a7">00187</a> <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a7">Logger::setMinLogLevel</a>( <font class="keywordtype">int</font> iLevel )00188 {00189 <a class="code" href="classLogger.html#o2">iMinLogLevel</a> = ( iLevel > 0 ) ? iLevel : 0;00190 <font class="keywordflow">return</font> <font class="keyword">true</font>;00191 }00192 <a name="l00196"></a><a class="code" href="classLogger.html#a8">00196</a> <font class="keywordtype">int</font> <a class="code" href="classLogger.html#a8">Logger::getMaxLogLevel</a>( )<font class="keyword"> const</font>00197 <font class="keyword"></font>{00198 <font class="keywordflow">return</font> <a class="code" href="classLogger.html#o3">iMaxLogLevel</a>;00199 }00200 <a name="l00205"></a><a class="code" href="classLogger.html#a9">00205</a> <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a9">Logger::setMaxLogLevel</a>( <font class="keywordtype">int</font> iLevel )00206 {00207 <a class="code" href="classLogger.html#o3">iMaxLogLevel</a> = ( iLevel > 0 ) ? iLevel : 0;00208 <font class="keywordflow">return</font> <font class="keyword">true</font>;00209 }00210 <a name="l00214"></a><a class="code" href="classLogger.html#a10">00214</a> <font class="keywordtype">int</font> <a class="code" href="classLogger.html#a10">Logger::getExtraLogLevel</a>( )<font class="keyword"> const</font>00215 <font class="keyword"></font>{00216 <font class="keywordflow">return</font> <a class="code" href="classLogger.html#o4">iExtraLogLevel</a>;00217 }00218 <a name="l00223"></a><a class="code" href="classLogger.html#a11">00223</a> <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a11">Logger::setExtraLogLevel</a>( <font class="keywordtype">int</font> iLevel )00224 {00225 <a class="code" href="classLogger.html#o4">iExtraLogLevel</a> = iLevel;00226 <font class="keywordflow">return</font> <font class="keyword">true</font>;00227 }00228 00229 00230 <a name="l00234"></a><a class="code" href="classLogger.html#a12">00234</a> <font class="keywordtype">char</font>* <a class="code" href="classLogger.html#a12">Logger::getHeader</a>( )00235 {00236 <font class="keywordflow">return</font> <a class="code" href="classLogger.html#o5">strHeader</a>;00237 }00238 <a name="l00243"></a><a class="code" href="classLogger.html#a13">00243</a> <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a13">Logger::setHeader</a>( <font class="keywordtype">char</font> *str )00244 {00245 strcpy( <a class="code" href="classLogger.html#o5">strHeader</a>, str );00246 <font class="keywordflow">return</font> <font class="keyword">true</font>;00247 }00248 <a name="l00255"></a><a class="code" href="classLogger.html#a14">00255</a> <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a13">Logger::setHeader</a>( <font class="keywordtype">int</font> i1, <font class="keywordtype">int</font> i2 )00256 {00257 sprintf( <a class="code" href="classLogger.html#o5">strHeader</a>, <font class="stringliteral">"(%d, %d) "</font>, i1, i2 );00258 <font class="keywordflow">return</font> <font class="keyword">true</font>;00259 }00260 <a name="l00266"></a><a class="code" href="classLogger.html#a15">00266</a> <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a15">Logger::setOutputStream</a>( ostream& o )00267 {00268 <a class="code" href="classLogger.html#o6">os</a> = &o;00269 <font class="keywordflow">return</font> <font class="keyword">true</font>;00270 }00271 00272 <font class="comment">/******************************************************************************/</font>00273 <font class="comment">/*********************** CLASS TIMING *****************************************/</font>00274 <font class="comment">/******************************************************************************/</font>00275 <a name="l00280"></a><a class="code" href="classTiming.html#d0">00280</a> <font class="keywordtype">double</font> <a class="code" href="classTiming.html#d0">Timing::getTimeDifference</a>( <font class="keyword">struct</font> timeval tv1, <font class="keyword">struct</font> timeval tv2 )00281 {00282 00283 <font class="keywordflow">return</font> ((double)tv1.tv_sec + (double)tv1.tv_usec/1000000 ) -00284 ((double)tv2.tv_sec + (double)tv2.tv_usec/1000000 ) ;00285 }00286 <a name="l00293"></a><a class="code" href="classTiming.html#a0">00293</a> <font class="keywordtype">void</font> <a class="code" href="classTiming.html#a0">Timing::printTimeDiffWithText</a>( ostream &os, <font class="keywordtype">char</font> *str, <font class="keywordtype">int</font> iFactor )00294 {00295 <font class="comment">// set the with to 6 and fille remaining places with '0'.</font>00296 os <<setw(6)<< setfill(<font class="charliteral">'0'</font>)<< <a class="code" href="classTiming.html#a1">getElapsedTime</a>()*iFactor << <font class="stringliteral">":"</font> << str << endl;00297 }00298 <a name="l00302"></a><a class="code" href="classTiming.html#a1">00302</a> <font class="keywordtype">double</font> <a class="code" href="classTiming.html#a1">Timing::getElapsedTime</a>( )00303 {00304 <font class="keyword">struct </font>timeval time2;00305 gettimeofday( &time2, NULL );00306 <font class="keywordflow">return</font> <a class="code" href="classTiming.html#d0">getTimeDifference</a>( time2, <a class="code" href="classTiming.html#o0">time1</a> );00307 }00308 <a name="l00310"></a><a class="code" href="classTiming.html#a2">00310</a> <font class="keywordtype">void</font> <a class="code" href="classTiming.html#a2">Timing::restartTime</a>( )00311 {00312 gettimeofday( &<a class="code" href="classTiming.html#o0">time1</a>, NULL );00313 }00314 00315 00316 <font class="comment">/*****************************************************************************/</font>00317 <font class="comment">/**************************** TESTING PURPOSES *******************************/</font>00318 <font class="comment">/*****************************************************************************/</font>00319 00320 <font class="comment">/*</font>00321 <font class="comment">#include<sys/poll.h></font>00322 <font class="comment"></font>00323 <font class="comment">int main( void )</font>00324 <font class="comment">{</font>00325 <font class="comment"> ofstream fout( "temp.txt" );</font>00326 <font class="comment"> Logger log( fout, 0, 2 );</font>00327 <font class="comment"> log.log( 0, "hello" );</font>00328 <font class="comment"> log.setHeader( "jelle" );</font>00329 <font class="comment"> poll(0,0,1000);</font>00330 <font class="comment"> log.log( 2, "hello" );</font>00331 <font class="comment"> log.log( 3, "hello" );</font>00332 <font class="comment"> int j = 2;</font>00333 <font class="comment"> double i = 2.324234;</font>00334 <font class="comment"> printf( "hoi: "); fflush(stdout);</font>00335 <font class="comment"> log.logWithTime( 1, "|%f %d|", i, j);</font>00336 <font class="comment">}</font>00337 <font class="comment"></font>00338 <font class="comment">*/</font></pre></div><hr><address><small>Generated on Thu Mar 7 00:37:42 2002 for UvA Trilearn 2001 by<a href="http://www.doxygen.org/index.html"><img src="doxygen.gif" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.12 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, © 1997-2001</small></address></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?