⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _pion_logger_8hpp-source.html

📁 用c++编写http server的源码库,对socket等网络处理的代码可迅速转为己用.
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<a name="l00086"></a>00086 <a name="l00087"></a>00087 <span class="preprocessor">#elif defined(PION_HAVE_LOG4CPP)</span><a name="l00088"></a>00088 <span class="preprocessor"></span><a name="l00089"></a>00089 <a name="l00090"></a>00090     <span class="comment">// log4cpp headers</span><a name="l00091"></a>00091 <span class="preprocessor">    #include &lt;log4cpp/Category.hh&gt;</span><a name="l00092"></a>00092 <span class="preprocessor">    #include &lt;log4cpp/BasicLayout.hh&gt;</span><a name="l00093"></a>00093 <span class="preprocessor">    #include &lt;log4cpp/OstreamAppender.hh&gt;</span><a name="l00094"></a>00094 <a name="l00095"></a>00095     <span class="keyword">namespace </span>pion {<a name="l00096"></a>00096         <span class="keyword">typedef</span> log4cpp::Category*  <a class="code" href="namespacepion.html#917bc483e4f692504156efb93c11b322">PionLogger</a>;<a name="l00097"></a>00097     }<a name="l00098"></a>00098 <a name="l00099"></a>00099 <span class="preprocessor">    #define PION_LOG_CONFIG_BASIC   { log4cpp::OstreamAppender *app = new log4cpp::OstreamAppender("cout", &amp;std::cout); app-&gt;setLayout(new log4cpp::BasicLayout()); log4cpp::Category::getRoot().setAppender(app); }</span><a name="l00100"></a>00100 <span class="preprocessor"></span><span class="preprocessor">    #define PION_GET_LOGGER(NAME)   (&amp;log4cpp::Category::getInstance(NAME))</span><a name="l00101"></a>00101 <span class="preprocessor"></span><a name="l00102"></a>00102 <span class="preprocessor">    #define PION_LOG_SETLEVEL_DEBUG(LOG)    { LOG-&gt;setPriority(log4cpp::Priority::DEBUG); }</span><a name="l00103"></a>00103 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_INFO(LOG)     { LOG-&gt;setPriority(log4cpp::Priority::INFO); }</span><a name="l00104"></a>00104 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_WARN(LOG)     { LOG-&gt;setPriority(log4cpp::Priority::WARN); }</span><a name="l00105"></a>00105 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_ERROR(LOG)    { LOG-&gt;setPriority(log4cpp::Priority::ERROR); }</span><a name="l00106"></a>00106 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_FATAL(LOG)    { LOG-&gt;setPriority(log4cpp::Priority::FATAL); }</span><a name="l00107"></a>00107 <span class="preprocessor"></span><a name="l00108"></a>00108 <span class="preprocessor">    #define PION_LOG_DEBUG(LOG, MSG)    if (LOG-&gt;getPriority()&gt;=log4cpp::Priority::DEBUG) { LOG-&gt;debugStream() &lt;&lt; MSG; }</span><a name="l00109"></a>00109 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_INFO(LOG, MSG)     if (LOG-&gt;getPriority()&gt;=log4cpp::Priority::INFO) { LOG-&gt;infoStream() &lt;&lt; MSG; }</span><a name="l00110"></a>00110 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_WARN(LOG, MSG)     if (LOG-&gt;getPriority()&gt;=log4cpp::Priority::WARN) { LOG-&gt;warnStream() &lt;&lt; MSG; }</span><a name="l00111"></a>00111 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_ERROR(LOG, MSG)    if (LOG-&gt;getPriority()&gt;=log4cpp::Priority::ERROR) { LOG-&gt;errorStream() &lt;&lt; MSG; }</span><a name="l00112"></a>00112 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_FATAL(LOG, MSG)    if (LOG-&gt;getPriority()&gt;=log4cpp::Priority::FATAL) { LOG-&gt;fatalStream() &lt;&lt; MSG; }</span><a name="l00113"></a>00113 <span class="preprocessor"></span><a name="l00114"></a>00114 <a name="l00115"></a>00115 <span class="preprocessor">#elif defined(PION_HAVE_OSTREAM_LOGGING)</span><a name="l00116"></a>00116 <span class="preprocessor"></span><a name="l00117"></a>00117 <a name="l00118"></a>00118     <span class="comment">// Logging uses std::cout and std::cerr</span><a name="l00119"></a>00119 <span class="preprocessor">    #include &lt;iostream&gt;</span><a name="l00120"></a>00120 <span class="preprocessor">    #include &lt;ctime&gt;</span><a name="l00121"></a>00121 <a name="l00122"></a>00122     <span class="keyword">namespace </span>pion {<a name="l00123"></a>00123         <span class="keyword">enum</span> PionPriorityType {<a name="l00124"></a>00124             PION_PRIORITY_DEBUG, PION_PRIORITY_INFO, PION_PRIORITY_WARN,<a name="l00125"></a>00125             PION_PRIORITY_ERROR, PION_PRIORITY_FATAL<a name="l00126"></a>00126         };<a name="l00127"></a>00127         <span class="keyword">struct </span><a class="code" href="namespacepion.html#917bc483e4f692504156efb93c11b322">PionLogger</a> {<a name="l00128"></a>00128             <a class="code" href="namespacepion.html#917bc483e4f692504156efb93c11b322">PionLogger</a>(<span class="keyword">const</span> std::string&amp; name)<a name="l00129"></a>00129                 : m_name(name), m_priority(PION_PRIORITY_DEBUG) {}<a name="l00130"></a>00130             std::string         m_name;<a name="l00131"></a>00131             PionPriorityType    m_priority;<a name="l00132"></a>00132         };<a name="l00133"></a>00133     }<a name="l00134"></a>00134 <a name="l00135"></a>00135 <span class="preprocessor">    #define PION_LOG_CONFIG_BASIC   {}</span><a name="l00136"></a>00136 <span class="preprocessor"></span><span class="preprocessor">    #define PION_GET_LOGGER(NAME)   pion::PionLogger(NAME)</span><a name="l00137"></a>00137 <span class="preprocessor"></span><a name="l00138"></a>00138 <span class="preprocessor">    #define PION_LOG_SETLEVEL_DEBUG(LOG)    { LOG.m_priority = PION_PRIORITY_DEBUG; }</span><a name="l00139"></a>00139 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_INFO(LOG)     { LOG.m_priority = PION_PRIORITY_INFO; }</span><a name="l00140"></a>00140 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_WARN(LOG)     { LOG.m_priority = PION_PRIORITY_WARN; }</span><a name="l00141"></a>00141 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_ERROR(LOG)    { LOG.m_priority = PION_PRIORITY_ERROR; }</span><a name="l00142"></a>00142 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_FATAL(LOG)    { LOG.m_priority = PION_PRIORITY_FATAL; }</span><a name="l00143"></a>00143 <span class="preprocessor"></span><a name="l00144"></a>00144 <span class="preprocessor">    #define PION_LOG_DEBUG(LOG, MSG)    if (LOG.m_priority &lt;= PION_PRIORITY_DEBUG) { std::cout &lt;&lt; time(NULL) &lt;&lt; " DEBUG " &lt;&lt; LOG.m_name &lt;&lt; ' ' &lt;&lt; MSG &lt;&lt; std::endl; }</span><a name="l00145"></a>00145 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_INFO(LOG, MSG)     if (LOG.m_priority &lt;= PION_PRIORITY_INFO) { std::cout &lt;&lt; time(NULL) &lt;&lt; " INFO " &lt;&lt; LOG.m_name &lt;&lt; ' ' &lt;&lt; MSG &lt;&lt; std::endl; }</span><a name="l00146"></a>00146 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_WARN(LOG, MSG)     if (LOG.m_priority &lt;= PION_PRIORITY_WARN) { std::cerr &lt;&lt; time(NULL) &lt;&lt; " WARN " &lt;&lt; LOG.m_name &lt;&lt; ' ' &lt;&lt; MSG &lt;&lt; std::endl; }</span><a name="l00147"></a>00147 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_ERROR(LOG, MSG)    if (LOG.m_priority &lt;= PION_PRIORITY_ERROR) { std::cerr &lt;&lt; time(NULL) &lt;&lt; " ERROR " &lt;&lt; LOG.m_name &lt;&lt; ' ' &lt;&lt; MSG &lt;&lt; std::endl; }</span><a name="l00148"></a>00148 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_FATAL(LOG, MSG)    if (LOG.m_priority &lt;= PION_PRIORITY_FATAL) { std::cerr &lt;&lt; time(NULL) &lt;&lt; " FATAL " &lt;&lt; LOG.m_name &lt;&lt; ' ' &lt;&lt; MSG &lt;&lt; std::endl; }</span><a name="l00149"></a>00149 <span class="preprocessor"></span><a name="l00150"></a>00150 <a name="l00151"></a>00151 <span class="preprocessor">#else</span><a name="l00152"></a>00152 <span class="preprocessor"></span><a name="l00153"></a>00153     <span class="comment">// Logging is disabled -&gt; add do-nothing stubs for logging</span><a name="l00154"></a>00154     <span class="keyword">namespace </span>pion {<a name="l00155"></a><a class="code" href="namespacepion.html#917bc483e4f692504156efb93c11b322">00155</a>         <span class="keyword">typedef</span> <span class="keywordtype">int</span>     <a class="code" href="namespacepion.html#917bc483e4f692504156efb93c11b322">PionLogger</a>;<a name="l00156"></a>00156     }<a name="l00157"></a>00157 <a name="l00158"></a>00158 <span class="preprocessor">    #define PION_LOG_CONFIG_BASIC   {}</span><a name="l00159"></a>00159 <span class="preprocessor"></span><span class="preprocessor">    #define PION_GET_LOGGER(NAME)   0</span><a name="l00160"></a>00160 <span class="preprocessor"></span><a name="l00161"></a>00161     <span class="comment">// use "++LOG" to avoid warnings about LOG not being used</span><a name="l00162"></a>00162 <span class="preprocessor">    #define PION_LOG_SETLEVEL_DEBUG(LOG)    { if (false) ++LOG; }</span><a name="l00163"></a>00163 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_INFO(LOG)     { if (false) ++LOG; }</span><a name="l00164"></a>00164 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_WARN(LOG)     { if (false) ++LOG; }</span><a name="l00165"></a>00165 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_ERROR(LOG)    { if (false) ++LOG; }</span><a name="l00166"></a>00166 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_SETLEVEL_FATAL(LOG)    { if (false) ++LOG; }</span><a name="l00167"></a>00167 <span class="preprocessor"></span><a name="l00168"></a>00168     <span class="comment">// use "++LOG" to avoid warnings about LOG not being used</span><a name="l00169"></a>00169 <span class="preprocessor">    #define PION_LOG_DEBUG(LOG, MSG)    { if (false) ++LOG; }</span><a name="l00170"></a>00170 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_INFO(LOG, MSG)     { if (false) ++LOG; }</span><a name="l00171"></a>00171 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_WARN(LOG, MSG)     { if (false) ++LOG; }</span><a name="l00172"></a>00172 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_ERROR(LOG, MSG)    { if (false) ++LOG; }</span><a name="l00173"></a>00173 <span class="preprocessor"></span><span class="preprocessor">    #define PION_LOG_FATAL(LOG, MSG)    { if (false) ++LOG; }</span><a name="l00174"></a>00174 <span class="preprocessor"></span><a name="l00175"></a>00175 <a name="l00176"></a>00176 <span class="preprocessor">#endif</span><a name="l00177"></a>00177 <span class="preprocessor"></span><a name="l00178"></a>00178 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 19 13:29:22 2007 for libpion by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.2 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -