logger_8h-source.html
来自「仿真人工智能是指用人工的方法和技术」· HTML 代码 · 共 119 行
HTML
119 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Logger.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body bgcolor="#ffffff"><!-- Generated by Doxygen 1.2.12 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>Logger.h</h1><a href="Logger_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/*</font>00002 <font class="comment">Copyright (c) 2000,2001, Jelle Kok, University of Amsterdam</font>00003 <font class="comment">All rights reserved.</font>00004 <font class="comment"></font>00005 <font class="comment">Redistribution and use in source and binary forms, with or without </font>00006 <font class="comment">modification, are permitted provided that the following conditions are met:</font>00007 <font class="comment"></font>00008 <font class="comment">1. Redistributions of source code must retain the above copyright notice, this </font>00009 <font class="comment">list of conditions and the following disclaimer. </font>00010 <font class="comment"></font>00011 <font class="comment">2. Redistributions in binary form must reproduce the above copyright notice, </font>00012 <font class="comment">this list of conditions and the following disclaimer in the documentation </font>00013 <font class="comment">and/or other materials provided with the distribution. </font>00014 <font class="comment"></font>00015 <font class="comment">3. Neither the name of the University of Amsterdam nor the names of its </font>00016 <font class="comment">contributors may be used to endorse or promote products derived from this </font>00017 <font class="comment">software without specific prior written permission. </font>00018 <font class="comment"></font>00019 <font class="comment">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" </font>00020 <font class="comment">AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE </font>00021 <font class="comment">IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE </font>00022 <font class="comment">DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE </font>00023 <font class="comment">FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL </font>00024 <font class="comment">DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR </font>00025 <font class="comment">SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER </font>00026 <font class="comment">CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, </font>00027 <font class="comment">OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE </font>00028 <font class="comment">OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</font>00029 <font class="comment">*/</font>00045 <font class="preprocessor">#ifndef _LOGGER_</font>00046 <font class="preprocessor"></font><font class="preprocessor">#define _LOGGER_</font>00047 <font class="preprocessor"></font>00048 <font class="preprocessor">#include <ostream.h></font> <font class="comment">// needed for ostream (logging to output stream)</font>00049 <font class="preprocessor">#include <fstream.h></font> <font class="comment">// needed for fstream (logging to file)</font>00050 <font class="preprocessor">#include <sys/time.h></font> <font class="comment">// needed for timeval</font>00051 <font class="preprocessor">#include <string></font> <font class="comment">// needed for string</font>00052 <font class="preprocessor">#include <iomanip></font> <font class="comment">// needed for setw</font>00053 <a name="l00054"></a><a class="code" href="Logger_8h.html#a0">00054</a> <font class="preprocessor">#define MAX_LOG_LINE 2048 </font><a name="l00055"></a><a class="code" href="Logger_8h.html#a1">00055</a> <font class="preprocessor">#define MAX_HEADER 128 </font>00056 <font class="preprocessor"></font><font class="comment">/******************************************************************************/</font>00057 <font class="comment">/*********************** CLASS TIMING *****************************************/</font>00058 <font class="comment">/******************************************************************************/</font>00059 <a name="l00062"></a><a class="code" href="classTiming.html">00062</a> <font class="keyword">class </font><a class="code" href="classTiming.html">Timing</a>00063 {<a name="l00064"></a><a class="code" href="classTiming.html#o0">00064</a> <font class="keyword">struct </font>timeval <a class="code" href="classTiming.html#o0">time1</a>; 00066 <font class="keyword">public</font>:00067 <font class="comment">// methods to restart the timer, get the elapsed time and print messages</font>00068 <font class="keyword">static</font> <font class="keywordtype">double</font> <a class="code" href="classTiming.html#d0">getTimeDifference</a> ( <font class="keyword">struct</font> timeval t1,00069 <font class="keyword">struct</font> timeval t2 );00070 <font class="keywordtype">void</font> <a class="code" href="classTiming.html#a0">printTimeDiffWithText</a>( ostream& os,00071 <font class="keywordtype">char</font> *str,00072 <font class="keywordtype">int</font> iFactor = 1000 );00073 <font class="keywordtype">double</font> <a class="code" href="classTiming.html#a1">getElapsedTime</a> ( );00074 <font class="keywordtype">void</font> <a class="code" href="classTiming.html#a2">restartTime</a> ( );00075 } ;00076 00077 00078 <font class="comment">/*****************************************************************************/</font>00079 <font class="comment">/**************************** LOGGER *****************************************/</font>00080 <font class="comment">/*****************************************************************************/</font>00081 <a name="l00094"></a><a class="code" href="classLogger.html">00094</a> <font class="keyword">class </font><a class="code" href="classLogger.html">Logger</a>00095 {<a name="l00096"></a><a class="code" href="classLogger.html#o0">00096</a> <a class="code" href="classTiming.html">Timing</a> <a class="code" href="classLogger.html#o0">timing</a>; <a name="l00097"></a><a class="code" href="classLogger.html#o1">00097</a> <font class="keywordtype">char</font> <a class="code" href="classLogger.html#o1">buf</a>[<a class="code" href="Logger_8h.html#a0">MAX_LOG_LINE</a>]; <a name="l00098"></a><a class="code" href="classLogger.html#o2">00098</a> <font class="keywordtype">int</font> <a class="code" href="classLogger.html#o2">iMinLogLevel</a>; <a name="l00099"></a><a class="code" href="classLogger.html#o3">00099</a> <font class="keywordtype">int</font> <a class="code" href="classLogger.html#o3">iMaxLogLevel</a>; <a name="l00100"></a><a class="code" href="classLogger.html#o4">00100</a> <font class="keywordtype">int</font> <a class="code" href="classLogger.html#o4">iExtraLogLevel</a>; <a name="l00101"></a><a class="code" href="classLogger.html#o5">00101</a> <font class="keywordtype">char</font> <a class="code" href="classLogger.html#o5">strHeader</a>[<a class="code" href="Logger_8h.html#a1">MAX_HEADER</a>];<a name="l00102"></a><a class="code" href="classLogger.html#o6">00102</a> ostream* <a class="code" href="classLogger.html#o6">os</a>; 00104 <font class="keyword">public</font>:00105 <a class="code" href="classLogger.html#a0">Logger</a>( ostream& <a class="code" href="classLogger.html#o6">os</a>=cout, <font class="keywordtype">int</font> <a class="code" href="classLogger.html#o2">iMinLogLevel</a>=0, <font class="keywordtype">int</font> <a class="code" href="classLogger.html#o3">iMaxLogLevel</a> = 0);00106 00107 <font class="comment">// different methods associated with logging messages</font>00108 <font class="comment">// bool log ( int iLevel, char *str, string str );</font>00109 <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a1">log</a> ( <font class="keywordtype">int</font> iLevel, string str );00110 <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a1">log</a> ( <font class="keywordtype">int</font> i, <font class="keywordtype">char</font> *str, ... );00111 <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a3">logWithTime</a> ( <font class="keywordtype">int</font> iLevel, <font class="keywordtype">char</font> *str, ... );00112 <font class="keywordtype">void</font> <a class="code" href="classLogger.html#a4">restartTimer</a> ( );00113 00114 <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a5">isInLogLevel</a> ( <font class="keywordtype">int</font> iLevel );00115 00116 <font class="comment">// standard get and set methods for the different member variables</font>00117 <font class="keywordtype">int</font> <a class="code" href="classLogger.html#a6">getMinLogLevel</a> ( ) <font class="keyword">const</font>;00118 <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a7">setMinLogLevel</a> ( <font class="keywordtype">int</font> iLevel );00119 00120 <font class="keywordtype">int</font> <a class="code" href="classLogger.html#a8">getMaxLogLevel</a> ( ) <font class="keyword">const</font>;00121 <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a9">setMaxLogLevel</a> ( <font class="keywordtype">int</font> iLevel );00122 00123 <font class="keywordtype">int</font> <a class="code" href="classLogger.html#a10">getExtraLogLevel</a> ( ) <font class="keyword">const</font>;00124 <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a11">setExtraLogLevel</a> ( <font class="keywordtype">int</font> iLevel );00125 00126 <font class="keywordtype">char</font>* <a class="code" href="classLogger.html#a12">getHeader</a> ( );00127 <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a13">setHeader</a> ( <font class="keywordtype">char</font> *str );00128 <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a13">setHeader</a> ( <font class="keywordtype">int</font> i1, <font class="keywordtype">int</font> i2 );00129 00130 <font class="keywordtype">bool</font> <a class="code" href="classLogger.html#a15">setOutputStream</a> ( ostream& <a class="code" href="classLogger.html#o6">os</a> );00131 };00132 00133 00134 <font class="preprocessor">#endif</font></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 + -
显示快捷键?