<!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>Log class Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.2.17 --> <center> <a class="qindex" href="main.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="classes.html">Alphabetical List</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> <a class="qindex" href="pages.html">Related Pages</a> </center> <hr><h1>Log Class Reference</h1><code>#include <<a class="el" href="log_8h-source.html">log.h</a>></code> <p> <a href="classLog-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0> <tr><td></td></tr> <tr><td colspan=2><br><h2>Public Methods</h2></td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classLog.html#a0">Log</a> (string &r_fname)</td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classLog.html#a1">Log</a> (const char *fname)</td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classLog.html#a2">~Log</a> ()</td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classLog.html#a3">Write</a> (const string &r_msg)</td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classLog.html#a4">Write</a> (const char *fmt,...)</td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classLog.html#a5">SetActive</a> (bool b)</td></tr> <tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classLog.html#a6">IsActive</a> ()</td></tr> <tr><td colspan=2><br><h2>Private Methods</h2></td></tr> <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classLog.html#c0">Log</a> (Log &)</td></tr> <tr><td nowrap align=right valign=top>Log & </td><td valign=bottom><a class="el" href="classLog.html#c1">operator=</a> (Log &)</td></tr> <tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classLog.html#c2">SetTime</a> ()</td></tr> <tr><td colspan=2><br><h2>Private Attributes</h2></td></tr> <tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classLog.html#o0">mFileName</a></td></tr> <tr><td> </td><td><font size=-1><em>log's filename or empty if cout (console)</em> <a href="#o0"></a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>ofstream * </td><td valign=bottom><a class="el" href="classLog.html#o1">mpFile</a></td></tr> <tr><td> </td><td><font size=-1><em>file stream or null if cout (console)</em> <a href="#o1"></a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classLog.html#o2">mActive</a></td></tr> <tr><td> </td><td><font size=-1><em>flag indicating if logging is on or off</em> <a href="#o2"></a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>char </td><td valign=bottom><a class="el" href="classLog.html#o3">mTimeStamp</a> [40]</td></tr> <tr><td> </td><td><font size=-1><em>current timestamp formatted <dl compact><dt><b>See also: </b></dt><dd> <a class="el" href="classLog.html#c2">SetTime</a></dl></em> <a href="#o3"></a><em></em></font><br><br></td></tr> <tr><td nowrap align=right valign=top>CRITICAL_SECTION </td><td valign=bottom><a class="el" href="classLog.html#o4">mMutex</a></td></tr> <tr><td> </td><td><font size=-1><em>To enforce mutual exclusion.</em> <a href="#o4"></a><em></em></font><br><br></td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> The Log class implements a simple logging mechanism to either a file stream, or to the cout console stream depending on whether constructed with a valid filename or empty filename (cout). Logging can be turned on and off by calling IsActive. <p> <dl compact><dt><b>Warning: </b></dt><dd> I'm not sure if all streams are threadsafe, therefore it would be prudent not to set up separate Logs for each subsystem.</dl><dl compact><dt><b><a class="el" href="todo.html#_todo000006">Todo: </a></b></dt><dd> Add different levels of logging, e.g. debug, trace, error, warning, info. Quite possibly performance instrumentation could belong in this class. </dl> <p> <p> Definition at line <a class="el" href="log_8h-source.html#l00030">30</a> of file <a class="el" href="log_8h-source.html">log.h</a>.<hr><h2>Constructor & Destructor Documentation</h2> <a name="a0" doxytag="Log::Log"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Log::Log </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">string & </td> <td class="mdname1" valign="top" nowrap> <em>r_fname</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Constructor for Log.<dl compact><dt><b>Parameters: </b></dt><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>r_fname</em> </td><td> A string that names the file to open. An empty string causes cout to be used for logging.</td></tr> </table> </dl><dl compact><dt><b><a class="el" href="todo.html#_todo000003">Todo: </a></b></dt><dd> Log is opened by default in append mode. A possible feature is to implement a overwrite/append toggle and/or automated log archival. </dl> <p> Definition at line <a class="el" href="log_8cpp-source.html#l00027">27</a> of file <a class="el" href="log_8cpp-source.html">log.cpp</a>. <p> References <a class="el" href="log_8h-source.html#l00046">mActive</a>, <a class="el" href="log_8h-source.html#l00044">mFileName</a>, <a class="el" href="log_8h-source.html#l00048">mMutex</a>, and <a class="el" href="log_8h-source.html#l00045">mpFile</a>. </td> </tr> </table> <a name="a1" doxytag="Log::Log"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Log::Log </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const char * </td> <td class="mdname1" valign="top" nowrap> <em>fname</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Constructor for Log.<dl compact><dt><b>Parameters: </b></dt><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>fname</em> </td><td> A pointer to a char array that names the file to open. An empty string causes cout to be used for logging.</td></tr> </table> </dl><dl compact><dt><b><a class="el" href="todo.html#_todo000004">Todo: </a></b></dt><dd> Log is opened by default in append mode. A possible feature is to implement a overwrite/append toggle and/or automated log archival. </dl> <p> Definition at line <a class="el" href="log_8cpp-source.html#l00048">48</a> of file <a class="el" href="log_8cpp-source.html">log.cpp</a>. <p> References <a class="el" href="log_8h-source.html#l00046">mActive</a>, <a class="el" href="log_8h-source.html#l00044">mFileName</a>, <a class="el" href="log_8h-source.html#l00048">mMutex</a>, and <a class="el" href="log_8h-source.html#l00045">mpFile</a>. </td> </tr> </table> <a name="a2" doxytag="Log::~Log"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Log::~Log </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Log destructor. <p> Definition at line <a class="el" href="log_8cpp-source.html#l00062">62</a> of file <a class="el" href="log_8cpp-source.html">log.cpp</a>. <p> References <a class="el" href="log_8h-source.html#l00048">mMutex</a>, and <a class="el" href="log_8h-source.html#l00045">mpFile</a>. </td> </tr> </table> <a name="c0" doxytag="Log::Log"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Log::Log </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">Log & </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [private]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <hr><h2>Member Function Documentation</h2> <a name="a6" doxytag="Log::IsActive"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> bool Log::IsActive </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> IsActive queries the whether logging is on or off. <p> <dl compact><dt><b>Returns :</b></dt><dd> true if logging is on active, false if logging off. </dl> <p> Definition at line <a class="el" href="log_8cpp-source.html#l00147">147</a> of file <a class="el" href="log_8cpp-source.html">log.cpp</a>. <p> References <a class="el" href="log_8h-source.html#l00046">mActive</a>, and <a class="el" href="log_8h-source.html#l00048">mMutex</a>. </td> </tr> </table> <a name="c1" doxytag="Log::operator="></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Log& Log::operator= </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">Log & </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [private]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> </td> </tr> </table> <a name="a5" doxytag="Log::SetActive"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void Log::SetActive </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">bool </td> <td class="mdname1" valign="top" nowrap> <em>b</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> SetActive turns logging on or off.<dl compact><dt><b>Parameters: </b></dt><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>b</em> </td><td> true sets logging on, false sets logging off. </td></tr> </table> </dl> <p> Definition at line <a class="el" href="log_8cpp-source.html#l00137">137</a> of file <a class="el" href="log_8cpp-source.html">log.cpp</a>. <p> References <a class="el" href="log_8h-source.html#l00046">mActive</a>, and <a class="el" href="log_8h-source.html#l00048">mMutex</a>. </td> </tr> </table> <a name="c2" doxytag="Log::SetTime"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void Log::SetTime </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [private]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> SetTime refreshes the log timestamp with the current time. <p> <dl compact><dt><b><a class="el" href="todo.html#_todo000005">Todo: </a></b></dt><dd> Could be enhanced by allowing the timestamp format to be specfified in the constructor or via a setter. </dl> <p> Definition at line <a class="el" href="log_8cpp-source.html#l00077">77</a> of file <a class="el" href="log_8cpp-source.html">log.cpp</a>. <p> References <a class="el" href="log_8h-source.html#l00047">mTimeStamp</a>. <p> Referenced by <a class="el" href="log_8cpp-source.html#l00089">Write</a>(). </td> </tr> </table> <a name="a4" doxytag="Log::Write"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void Log::Write </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const char * </td> <td class="mdname" nowrap> <em>fmt</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>... </td> <td class="mdname" nowrap> </td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Write a formatted message to the log.<dl compact><dt><b>Parameters: </b></dt><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>fmt</em> </td><td> A character array containing format specifiers of the message to be written. </td></tr> <tr><td valign=top><em>...</em> </td><td> Zero or more parameters depending on to the number of format specifiers used in fmt.</td></tr> </table> </dl><dl compact><dt><b>Warning: </b></dt><dd> Like printf, using the wrong number or types of format specifiers can and will be fatal.</dl><dl compact><dt><b><a class="el" href="bug.html#_bug000001">Bug: </a></b></dt><dd> Log messages that exceed 1024 characters after formatting will crash. </dl> <p> Definition at line <a class="el" href="log_8cpp-source.html#l00115">115</a> of file <a class="el" href="log_8cpp-source.html">log.cpp</a>. <p> References <a class="el" href="log_8h-source.html#l00048">mMutex</a>, <a class="el" href="log_8h-source.html#l00045">mpFile</a>, <a class="el" href="log_8h-source.html#l00047">mTimeStamp</a>, and <a class="el" href="log_8cpp-source.html#l00077">SetTime</a>(). </td> </tr> </table> <a name="a3" doxytag="Log::Write"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void Log::Write </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const string & </td> <td class="mdname1" valign="top" nowrap> <em>r_msg</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> Write a string message to the log.<dl compact><dt><b>Parameters: </b></dt><dd> <table border=0 cellspacing=2 cellpadding=0> <tr><td valign=top><em>r_msg</em> </td><td> A string containing the message to be written. </td></tr> </table> </dl> <p> Definition at line <a class="el" href="log_8cpp-source.html#l00089">89</a> of file <a class="el" href="log_8cpp-source.html">log.cpp</a>. <p> References <a class="el" href="log_8h-source.html#l00048">mMutex</a>, <a class="el" href="log_8h-source.html#l00045">mpFile</a>, <a class="el" href="log_8h-source.html#l00047">mTimeStamp</a>, and <a class="el" href="log_8cpp-source.html#l00077">SetTime</a>(). <p> Referenced by <a class="el" href="server_8cpp-source.html#l00174">Server::AcceptConnection</a>(), <a class="el" href="server_8cpp-source.html#l00041">Server::Boot</a>(), <a class="el" href="connection_8cpp-source.html#l00162">Connection::Disconnect</a>(), <a class="el" href="connection_8cpp-source.html#l00073">Connection::HandleInput</a>(), <a class="el" href="connection_8cpp-source.html#l00135">Connection::HandleOutput</a>(), <a class="el" href="paradigm_8cpp-source.html#l00175">main</a>(), <a class="el" href="server_8cpp-source.html#l00103">Server::Run</a>(), <a class="el" href="server_8cpp-source.html#l00325">Server::SetNonBlocking</a>(), and <a class="el" href="server_8cpp-source.html#l00291">Server::ShutdownServer</a>(). </td> </tr> </table> <hr><h2>Member Data Documentation</h2> <a name="o2" doxytag="Log::mActive"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> bool Log::mActive<code> [private]</code> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> flag indicating if logging is on or off <p> <p> Definition at line <a class="el" href="log_8h-source.html#l00046">46</a> of file <a class="el" href="log_8h-source.html">log.h</a>. <p> Referenced by <a class="el" href="log_8cpp-source.html#l00147">IsActive</a>(), <a class="el" href="log_8cpp-source.html#l00027">Log</a>(), and <a class="el" href="log_8cpp-source.html#l00137">SetActive</a>(). </td> </tr> </table> <a name="o0" doxytag="Log::mFileName"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> string Log::mFileName<code> [private]</code> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> log's filename or empty if cout (console) <p> <p> Definition at line <a class="el" href="log_8h-source.html#l00044">44</a> of file <a class="el" href="log_8h-source.html">log.h</a>. <p> Referenced by <a class="el" href="log_8cpp-source.html#l00027">Log</a>(). </td> </tr> </table> <a name="o4" doxytag="Log::mMutex"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> CRITICAL_SECTION Log::mMutex<code> [private]</code> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> To enforce mutual exclusion. <p> <p> Definition at line <a class="el" href="log_8h-source.html#l00048">48</a> of file <a class="el" href="log_8h-source.html">log.h</a>. <p> Referenced by <a class="el" href="log_8cpp-source.html#l00147">IsActive</a>(), <a class="el" href="log_8cpp-source.html#l00027">Log</a>(), <a class="el" href="log_8cpp-source.html#l00137">SetActive</a>(), <a class="el" href="log_8cpp-source.html#l00089">Write</a>(), and <a class="el" href="log_8cpp-source.html#l00062">~Log</a>(). </td> </tr> </table> <a name="o1" doxytag="Log::mpFile"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> ofstream* Log::mpFile<code> [private]</code> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> file stream or null if cout (console) <p> <p> Definition at line <a class="el" href="log_8h-source.html#l00045">45</a> of file <a class="el" href="log_8h-source.html">log.h</a>. <p> Referenced by <a class="el" href="log_8cpp-source.html#l00027">Log</a>(), <a class="el" href="log_8cpp-source.html#l00089">Write</a>(), and <a class="el" href="log_8cpp-source.html#l00062">~Log</a>(). </td> </tr> </table> <a name="o3" doxytag="Log::mTimeStamp"></a><p> <table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> char Log::mTimeStamp[40]<code> [private]</code> </table> </td> </tr> </table> <table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td> <p> current timestamp formatted <dl compact><dt><b>See also: </b></dt><dd> <a class="el" href="classLog.html#c2">SetTime</a></dl> <p> <p> Definition at line <a class="el" href="log_8h-source.html#l00047">47</a> of file <a class="el" href="log_8h-source.html">log.h</a>. <p> Referenced by <a class="el" href="log_8cpp-source.html#l00077">SetTime</a>(), and <a class="el" href="log_8cpp-source.html#l00089">Write</a>(). </td> </tr> </table> <hr>The documentation for this class was generated from the following files:<ul> <li><a class="el" href="log_8h-source.html">log.h</a><li><a class="el" href="log_8cpp-source.html">log.cpp</a></ul> <hr><address style="align: right;"><small>Generated on Mon Mar 29 23:12:57 2004 for Paradigm by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.17 </small></address> </body> </html>