Sophie

Sophie

distrib > Mandriva > 2009.1 > x86_64 > media > contrib-release > by-pkgid > 24b00a2a0eb5a285df26cd26c1ede933 > files > 70

lib64rlog1-devel-1.3.7-2mdv2008.1.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>rlog: rlog.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.3 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<div class="nav">
<a class="el" href="dir_000001.html">rlog-1.3.7</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_000002.html">rlog</a></div>
<h1>rlog-1.3.7/rlog/rlog.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*****************************************************************************</span>
<a name="l00002"></a>00002 <span class="comment"> * Author:   Valient Gough &lt;vgough@pobox.com&gt;</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> *****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> * Copyright (c) 2002-2004, Valient Gough</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> * This library is free software; you can distribute it and/or modify it under</span>
<a name="l00008"></a>00008 <span class="comment"> * the terms of the GNU Lesser General Public License (LGPL), as published by</span>
<a name="l00009"></a>00009 <span class="comment"> * the Free Software Foundation; either version 2.1 of the License, or (at your</span>
<a name="l00010"></a>00010 <span class="comment"> * option) any later version.</span>
<a name="l00011"></a>00011 <span class="comment"> *</span>
<a name="l00012"></a>00012 <span class="comment"> * This library is distributed in the hope that it will be useful, but WITHOUT</span>
<a name="l00013"></a>00013 <span class="comment"> * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</span>
<a name="l00014"></a>00014 <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE.  See the LGPL in the file COPYING for more</span>
<a name="l00015"></a>00015 <span class="comment"> * details.</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> */</span>
<a name="l00018"></a>00018                                                                                                 
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#ifndef _rlog_incl_</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define _rlog_incl_</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span>
<a name="l00023"></a>00023 <span class="preprocessor">#define CONCAT2(A,B) A##B</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define CONCAT(A,B) CONCAT2(A,B)</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#define STR(X) #X</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;rlog/common.h&gt;</span>
<a name="l00028"></a>00028 
<a name="l00034"></a>00034 <span class="comment">// may be useful for checking from configuration files</span>
<a name="l00035"></a>00035 <span class="preprocessor">#define CURRENT_RLOG_VERSION 20040503</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> <span class="keywordtype">int</span> RLogVersion();
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="keyword">namespace </span>rlog
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040 
<a name="l00041"></a>00041     <span class="keyword">class </span>RLogChannel;
<a name="l00042"></a>00042     <span class="keyword">class </span>RLogPublisher;
<a name="l00043"></a>00043     <span class="keyword">class </span>RLogNode;
<a name="l00044"></a>00044 
<a name="l00048"></a>00048     <span class="keyword">enum</span> LogLevel
<a name="l00049"></a>00049     {
<a name="l00050"></a>00050         Log_Undef    =0, 
<a name="l00051"></a>00051         Log_Critical,    
<a name="l00052"></a>00052         Log_Error,       
<a name="l00053"></a>00053         Log_Warning,     
<a name="l00054"></a>00054         Log_Notice,      
<a name="l00055"></a>00055         Log_Info,        
<a name="l00056"></a>00056         Log_Debug        
<a name="l00057"></a>00057     };
<a name="l00058"></a>00058 
<a name="l00069"></a>00069     <span class="keywordtype">void</span> RLOG_DECL RLogInit(<span class="keywordtype">int</span> &amp;argc, <span class="keywordtype">char</span> **argv);
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 
<a name="l00072"></a>00072     <span class="comment">// Get channel with a particular component name</span>
<a name="l00073"></a>00073     RLOG_DECL RLogChannel *GetComponentChannel(<span class="keyword">const</span> <span class="keywordtype">char</span> *component, 
<a name="l00074"></a>00074                                      <span class="keyword">const</span> <span class="keywordtype">char</span> *path, 
<a name="l00075"></a>00075                                      LogLevel level = Log_Undef);
<a name="l00076"></a>00076 
<a name="l00077"></a>00077     <span class="comment">// the global channel receives messages for all components</span>
<a name="l00078"></a>00078     RLOG_DECL RLogChannel *GetGlobalChannel( <span class="keyword">const</span> <span class="keywordtype">char</span> *path,
<a name="l00079"></a>00079                                    LogLevel level = Log_Undef);
<a name="l00080"></a>00080 
<a name="l00124"></a>00124 <span class="preprocessor">#define DEF_CHANNEL(path,level) RLOG_CHANNEL_IMPL(RLOG_COMPONENT, path, level)</span>
<a name="l00125"></a>00125 <span class="preprocessor"></span><span class="preprocessor">#define RLOG_CHANNEL(path) RLOG_CHANNEL_IMPL(RLOG_COMPONENT, path, rlog::Log_Undef)</span>
<a name="l00126"></a>00126 <span class="preprocessor"></span><span class="preprocessor">#define RLOG_CHANNEL_IMPL(COMPONENT,path,level) \</span>
<a name="l00127"></a>00127 <span class="preprocessor">    rlog::GetComponentChannel(STR(COMPONENT),path,level)</span>
<a name="l00128"></a>00128 <span class="preprocessor"></span>
<a name="l00129"></a>00129     <span class="comment">/*</span>
<a name="l00130"></a>00130 <span class="comment">        Pre-defined channels, </span>
<a name="l00131"></a>00131 <span class="comment">        "debug", "warning", and "error".</span>
<a name="l00132"></a>00132 <span class="comment"></span>
<a name="l00133"></a>00133 <span class="comment">        You can of course defined sub-channels based on the predefined types,</span>
<a name="l00134"></a>00134 <span class="comment">        such as "debug/level1", or whatever.</span>
<a name="l00135"></a>00135 <span class="comment">    */</span>
<a name="l00136"></a>00136     <span class="keyword">extern</span> RLOG_DECL RLogChannel *_RLDebugChannel;
<a name="l00137"></a>00137     <span class="keyword">extern</span> RLOG_DECL RLogChannel *_RLInfoChannel;
<a name="l00138"></a>00138     <span class="keyword">extern</span> RLOG_DECL RLogChannel *_RLWarningChannel;
<a name="l00139"></a>00139     <span class="keyword">extern</span> RLOG_DECL RLogChannel *_RLErrorChannel;
<a name="l00140"></a>00140 
<a name="l00153"></a><a class="code" href="structrlog_1_1PublishLoc.html">00153</a>     <span class="keyword">struct </span>PublishLoc
<a name="l00154"></a>00154     {
<a name="l00155"></a>00155         <span class="comment">// If the compiler supports printf attribute specification on function</span>
<a name="l00156"></a>00156         <span class="comment">// pointers, we'll use it here so that the compiler knows to check for</span>
<a name="l00157"></a>00157         <span class="comment">// proper printf formatting.  If it doesn't support it, then we'll</span>
<a name="l00158"></a>00158         <span class="comment">// force the check by inserting a bogus inline function..</span>
<a name="l00160"></a>00160 <span class="comment"></span>        void (*<a class="code" href="structrlog_1_1PublishLoc.html#o0">publish</a>)(PublishLoc *, RLogChannel *, <span class="keyword">const</span> <span class="keywordtype">char</span> *format, ... )
<a name="l00161"></a>00161             PRINTF_FP(3,4);
<a name="l00162"></a>00162         RLogNode *pub;
<a name="l00163"></a>00163         <span class="keyword">const</span> <span class="keywordtype">char</span> *component;
<a name="l00164"></a>00164         <span class="keyword">const</span> <span class="keywordtype">char</span> *fileName;
<a name="l00165"></a>00165         <span class="keyword">const</span> <span class="keywordtype">char</span> *functionName;
<a name="l00166"></a>00166         <span class="keywordtype">int</span> lineNum;
<a name="l00167"></a>00167         RLogChannel *channel;
<a name="l00168"></a>00168     };
<a name="l00169"></a>00169 
<a name="l00176"></a>00176     <span class="keywordtype">void</span> RLOG_DECL RLog_Register(PublishLoc *loc, RLogChannel *, 
<a name="l00177"></a>00177                        <span class="keyword">const</span> <span class="keywordtype">char</span> *format, ... ) PRINTF(3,4);
<a name="l00178"></a>00178 
<a name="l00184"></a>00184     <span class="keywordtype">void</span> RLOG_DECL rAssertFailed( const <span class="keywordtype">char</span> *component, const <span class="keywordtype">char</span> *file, 
<a name="l00185"></a>00185                         const <span class="keywordtype">char</span> *function, <span class="keywordtype">int</span> line, 
<a name="l00186"></a>00186                         const <span class="keywordtype">char</span> *conditionStr );
<a name="l00187"></a>00187 
<a name="l00188"></a>00188     <span class="comment">// if we don't have printf attributes on function pointers, but we do have</span>
<a name="l00189"></a>00189     <span class="comment">// printf attributes, then make a bogus check function..</span>
<a name="l00190"></a>00190 #if !HAVE_PRINTF_FP &amp;&amp; HAVE_PRINTF_ATTR
<a name="l00191"></a>00191     <span class="keywordtype">void</span> __checkArgs(<span class="keywordtype">int</span>, const <span class="keywordtype">char</span> *, ... ) PRINTF(2,3);
<a name="l00192"></a>00192 
<a name="l00193"></a>00193     inline <span class="keywordtype">void</span> __checkArgs(<span class="keywordtype">int</span>, const <span class="keywordtype">char</span> *, ...)
<a name="l00194"></a>00194     { }
<a name="l00195"></a>00195 <span class="preprocessor">#endif</span>
<a name="l00196"></a>00196 <span class="preprocessor"></span>}
<a name="l00197"></a>00197 
<a name="l00198"></a>00198 <span class="preprocessor">#if C99_VARIADAC_MACROS</span>
<a name="l00199"></a>00199 <span class="preprocessor"></span><span class="preprocessor">#include &lt;rlog/rlog-c99.h&gt;</span>
<a name="l00200"></a>00200 <span class="preprocessor">#elif PREC99_VARIADAC_MACROS</span>
<a name="l00201"></a>00201 <span class="preprocessor"></span><span class="preprocessor">#include &lt;rlog/rlog-prec99.h&gt;</span>
<a name="l00202"></a>00202 <span class="preprocessor">#else</span>
<a name="l00203"></a>00203 <span class="preprocessor"></span><span class="preprocessor">#include &lt;rlog/rlog-novariadic.h&gt;</span>
<a name="l00204"></a>00204 <span class="preprocessor">#endif</span>
<a name="l00205"></a>00205 <span class="preprocessor"></span>
<a name="l00206"></a>00206 
<a name="l00207"></a>00207 <span class="preprocessor">#define _rAssertFailed(COMPONENT, COND) \</span>
<a name="l00208"></a>00208 <span class="preprocessor">    rlog::rAssertFailed(STR(COMPONENT),__FILE__,__FUNCTION__,__LINE__, COND)</span>
<a name="l00209"></a>00209 <span class="preprocessor"></span>
<a name="l00220"></a>00220 <span class="preprocessor">#define rAssert( cond ) \</span>
<a name="l00221"></a>00221 <span class="preprocessor">    do { \</span>
<a name="l00222"></a>00222 <span class="preprocessor">        if( unlikely((cond) == false) ) \</span>
<a name="l00223"></a>00223 <span class="preprocessor">        { rError( "Assert failed: " STR(cond) ); \</span>
<a name="l00224"></a>00224 <span class="preprocessor">          _rAssertFailed(RLOG_COMPONENT, STR(cond)); \</span>
<a name="l00225"></a>00225 <span class="preprocessor">        } \</span>
<a name="l00226"></a>00226 <span class="preprocessor">    } while(0)</span>
<a name="l00227"></a>00227 <span class="preprocessor"></span>
<a name="l00235"></a>00235 <span class="preprocessor">#define rAssertSilent( cond ) \</span>
<a name="l00236"></a>00236 <span class="preprocessor">    do { \</span>
<a name="l00237"></a>00237 <span class="preprocessor">        if( unlikely((cond) == false) ) \</span>
<a name="l00238"></a>00238 <span class="preprocessor">        { _rAssertFailed(RLOG_COMPONENT, STR(cond)); } \</span>
<a name="l00239"></a>00239 <span class="preprocessor">    } while(0)</span>
<a name="l00240"></a>00240 <span class="preprocessor"></span>
<a name="l00241"></a>00241 
<a name="l00246"></a>00246 <span class="comment">/* @def RLOG_NO_COPY</span>
<a name="l00247"></a>00247 <span class="comment">    @brief Disables class copy constructor and operator =.</span>
<a name="l00248"></a>00248 <span class="comment"></span>
<a name="l00249"></a>00249 <span class="comment">    This macro declares a private copy constructor and assignment operator</span>
<a name="l00250"></a>00250 <span class="comment">    which prevents automatic generation of these operation by the compiler.</span>
<a name="l00251"></a>00251 <span class="comment"></span>
<a name="l00252"></a>00252 <span class="comment">    Attention, it switches access to private, so use it only at the end of the</span>
<a name="l00253"></a>00253 <span class="comment">    class declaration.</span>
<a name="l00254"></a>00254 <span class="comment">    */</span>
<a name="l00255"></a>00255 <span class="preprocessor">#define RLOG_NO_COPY(CNAME) \</span>
<a name="l00256"></a>00256 <span class="preprocessor">    private: \</span>
<a name="l00257"></a>00257 <span class="preprocessor">        CNAME(const CNAME&amp;); \</span>
<a name="l00258"></a>00258 <span class="preprocessor">        CNAME &amp; operator = (const CNAME &amp;)</span>
<a name="l00259"></a>00259 <span class="preprocessor"></span>
<a name="l00260"></a>00260 
<a name="l00261"></a>00261 <span class="preprocessor">#endif // rlog.h</span>
<a name="l00262"></a>00262 <span class="preprocessor"></span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Oct 5 11:13:40 2005 for rlog by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.3 </small></address>
</body>
</html>