group__log.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.11"/>
  7. <title>libwebsockets: Logging</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <script type="text/javascript" src="jquery.js"></script>
  10. <script type="text/javascript" src="dynsections.js"></script>
  11. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  12. <script type="text/javascript" src="resize.js"></script>
  13. <script type="text/javascript" src="navtreedata.js"></script>
  14. <script type="text/javascript" src="navtree.js"></script>
  15. <script type="text/javascript">
  16. $(document).ready(initResizable);
  17. $(window).load(resizeHeight);
  18. </script>
  19. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  20. </head>
  21. <body>
  22. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  23. <div id="titlearea">
  24. <table cellspacing="0" cellpadding="0">
  25. <tbody>
  26. <tr style="height: 56px;">
  27. <td id="projectlogo"><img alt="Logo" src="libwebsockets.org-logo.png"/></td>
  28. <td id="projectalign" style="padding-left: 0.5em;">
  29. <div id="projectname">libwebsockets
  30. </div>
  31. <div id="projectbrief">Lightweight C library for HTML5 websockets</div>
  32. </td>
  33. </tr>
  34. </tbody>
  35. </table>
  36. </div>
  37. <!-- end header part -->
  38. <!-- Generated by Doxygen 1.8.11 -->
  39. <div id="navrow1" class="tabs">
  40. <ul class="tablist">
  41. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  42. <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
  43. <li class="current"><a href="modules.html"><span>Modules</span></a></li>
  44. <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
  45. <li><a href="files.html"><span>Files</span></a></li>
  46. </ul>
  47. </div>
  48. </div><!-- top -->
  49. <div id="side-nav" class="ui-resizable side-nav-resizable">
  50. <div id="nav-tree">
  51. <div id="nav-tree-contents">
  52. <div id="nav-sync" class="sync"></div>
  53. </div>
  54. </div>
  55. <div id="splitbar" style="-moz-user-select:none;"
  56. class="ui-resizable-handle">
  57. </div>
  58. </div>
  59. <script type="text/javascript">
  60. $(document).ready(function(){initNavTree('group__log.html','');});
  61. </script>
  62. <div id="doc-content">
  63. <div class="header">
  64. <div class="summary">
  65. <a href="#enum-members">Enumerations</a> &#124;
  66. <a href="#func-members">Functions</a> </div>
  67. <div class="headertitle">
  68. <div class="title">Logging</div> </div>
  69. </div><!--header-->
  70. <div class="contents">
  71. <table class="memberdecls">
  72. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
  73. Enumerations</h2></td></tr>
  74. <tr class="memitem:ga14542b84d2c76efa7814124bb10f9c5f"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga14542b84d2c76efa7814124bb10f9c5f"></a>enum &#160;</td><td class="memItemRight" valign="bottom"><b>lws_log_levels</b> { <br />
  75. &#160;&#160;<b>LLL_ERR</b> = 1 &lt;&lt; 0,
  76. <b>LLL_WARN</b> = 1 &lt;&lt; 1,
  77. <b>LLL_NOTICE</b> = 1 &lt;&lt; 2,
  78. <b>LLL_INFO</b> = 1 &lt;&lt; 3,
  79. <br />
  80. &#160;&#160;<b>LLL_DEBUG</b> = 1 &lt;&lt; 4,
  81. <b>LLL_PARSER</b> = 1 &lt;&lt; 5,
  82. <b>LLL_HEADER</b> = 1 &lt;&lt; 6,
  83. <b>LLL_EXT</b> = 1 &lt;&lt; 7,
  84. <br />
  85. &#160;&#160;<b>LLL_CLIENT</b> = 1 &lt;&lt; 8,
  86. <b>LLL_LATENCY</b> = 1 &lt;&lt; 9,
  87. <b>LLL_COUNT</b> = 10
  88. <br />
  89. }</td></tr>
  90. <tr class="separator:ga14542b84d2c76efa7814124bb10f9c5f"><td class="memSeparator" colspan="2">&#160;</td></tr>
  91. </table><table class="memberdecls">
  92. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
  93. Functions</h2></td></tr>
  94. <tr class="memitem:gaf5f07837692b2f231a79da8a058288aa"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaf5f07837692b2f231a79da8a058288aa"></a>
  95. LWS_VISIBLE LWS_EXTERN void&#160;</td><td class="memItemRight" valign="bottom"><b>_lws_log</b> (int filter, const char *format,...)</td></tr>
  96. <tr class="separator:gaf5f07837692b2f231a79da8a058288aa"><td class="memSeparator" colspan="2">&#160;</td></tr>
  97. <tr class="memitem:ga74eb146969f0595e12ea835851b4588e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga74eb146969f0595e12ea835851b4588e"></a>
  98. LWS_VISIBLE LWS_EXTERN void&#160;</td><td class="memItemRight" valign="bottom"><b>_lws_logv</b> (int filter, const char *format, va_list vl)</td></tr>
  99. <tr class="separator:ga74eb146969f0595e12ea835851b4588e"><td class="memSeparator" colspan="2">&#160;</td></tr>
  100. <tr class="memitem:ga42e39775c6b69b7251bdbf5a2cdd5dcd"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__log.html#ga42e39775c6b69b7251bdbf5a2cdd5dcd">lwsl_timestamp</a> (int level, char *p, int len)</td></tr>
  101. <tr class="separator:ga42e39775c6b69b7251bdbf5a2cdd5dcd"><td class="memSeparator" colspan="2">&#160;</td></tr>
  102. <tr class="memitem:ga898b1f03872ad019f507d4e35bbefa90"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__log.html#ga898b1f03872ad019f507d4e35bbefa90">lwsl_hexdump</a> (void *buf, size_t len)</td></tr>
  103. <tr class="separator:ga898b1f03872ad019f507d4e35bbefa90"><td class="memSeparator" colspan="2">&#160;</td></tr>
  104. <tr class="memitem:ga244647f9e1bf0097ccdde66d74f41e26"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__log.html#ga244647f9e1bf0097ccdde66d74f41e26">lws_set_log_level</a> (int level, void(*log_emit_function)(int level, const char *line))</td></tr>
  105. <tr class="separator:ga244647f9e1bf0097ccdde66d74f41e26"><td class="memSeparator" colspan="2">&#160;</td></tr>
  106. <tr class="memitem:gab7c0fc936cc9f1eb58e2bb234c15147c"><td class="memItemLeft" align="right" valign="top">LWS_VISIBLE LWS_EXTERN void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__log.html#gab7c0fc936cc9f1eb58e2bb234c15147c">lwsl_emit_syslog</a> (int level, const char *line)</td></tr>
  107. <tr class="separator:gab7c0fc936cc9f1eb58e2bb234c15147c"><td class="memSeparator" colspan="2">&#160;</td></tr>
  108. </table>
  109. <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
  110. <h2>Logging</h2>
  111. <p>Lws provides flexible and filterable logging facilities, which can be used inside lws and in user code.</p>
  112. <p>Log categories may be individually filtered bitwise, and directed to built-in sinks for syslog-compatible logging, or a user-defined function. </p>
  113. <h2 class="groupheader">Function Documentation</h2>
  114. <a class="anchor" id="ga244647f9e1bf0097ccdde66d74f41e26"></a>
  115. <div class="memitem">
  116. <div class="memproto">
  117. <table class="memname">
  118. <tr>
  119. <td class="memname">LWS_VISIBLE LWS_EXTERN void lws_set_log_level </td>
  120. <td>(</td>
  121. <td class="paramtype">int&#160;</td>
  122. <td class="paramname"><em>level</em>, </td>
  123. </tr>
  124. <tr>
  125. <td class="paramkey"></td>
  126. <td></td>
  127. <td class="paramtype">void(*)(int level, const char *line)&#160;</td>
  128. <td class="paramname"><em>log_emit_function</em>&#160;</td>
  129. </tr>
  130. <tr>
  131. <td></td>
  132. <td>)</td>
  133. <td></td><td></td>
  134. </tr>
  135. </table>
  136. </div><div class="memdoc">
  137. <p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
  138. <p><a class="el" href="group__log.html#ga244647f9e1bf0097ccdde66d74f41e26">lws_set_log_level()</a> - Set the logging bitfield </p><dl class="params"><dt>Parameters</dt><dd>
  139. <table class="params">
  140. <tr><td class="paramname">level</td><td>OR together the LLL_ debug contexts you want output from </td></tr>
  141. <tr><td class="paramname">log_emit_function</td><td>NULL to leave it as it is, or a user-supplied function to perform log string emission instead of the default stderr one.</td></tr>
  142. </table>
  143. </dd>
  144. </dl>
  145. <p>log level defaults to "err", "warn" and "notice" contexts enabled and emission on stderr. </p>
  146. </div>
  147. </div>
  148. <a class="anchor" id="gab7c0fc936cc9f1eb58e2bb234c15147c"></a>
  149. <div class="memitem">
  150. <div class="memproto">
  151. <table class="memname">
  152. <tr>
  153. <td class="memname">LWS_VISIBLE LWS_EXTERN void lwsl_emit_syslog </td>
  154. <td>(</td>
  155. <td class="paramtype">int&#160;</td>
  156. <td class="paramname"><em>level</em>, </td>
  157. </tr>
  158. <tr>
  159. <td class="paramkey"></td>
  160. <td></td>
  161. <td class="paramtype">const char *&#160;</td>
  162. <td class="paramname"><em>line</em>&#160;</td>
  163. </tr>
  164. <tr>
  165. <td></td>
  166. <td>)</td>
  167. <td></td><td></td>
  168. </tr>
  169. </table>
  170. </div><div class="memdoc">
  171. <p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
  172. <p><a class="el" href="group__log.html#gab7c0fc936cc9f1eb58e2bb234c15147c">lwsl_emit_syslog()</a> - helper log emit function writes to system log</p>
  173. <dl class="params"><dt>Parameters</dt><dd>
  174. <table class="params">
  175. <tr><td class="paramname">level</td><td>one of LLL_ log level indexes </td></tr>
  176. <tr><td class="paramname">line</td><td>log string</td></tr>
  177. </table>
  178. </dd>
  179. </dl>
  180. <p>You use this by passing the function pointer to <a class="el" href="group__log.html#ga244647f9e1bf0097ccdde66d74f41e26">lws_set_log_level()</a>, to set it as the log emit function, it is not called directly. </p>
  181. </div>
  182. </div>
  183. <a class="anchor" id="ga898b1f03872ad019f507d4e35bbefa90"></a>
  184. <div class="memitem">
  185. <div class="memproto">
  186. <table class="memname">
  187. <tr>
  188. <td class="memname">LWS_VISIBLE LWS_EXTERN void lwsl_hexdump </td>
  189. <td>(</td>
  190. <td class="paramtype">void *&#160;</td>
  191. <td class="paramname"><em>buf</em>, </td>
  192. </tr>
  193. <tr>
  194. <td class="paramkey"></td>
  195. <td></td>
  196. <td class="paramtype">size_t&#160;</td>
  197. <td class="paramname"><em>len</em>&#160;</td>
  198. </tr>
  199. <tr>
  200. <td></td>
  201. <td>)</td>
  202. <td></td><td></td>
  203. </tr>
  204. </table>
  205. </div><div class="memdoc">
  206. <p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
  207. <p><a class="el" href="group__log.html#ga898b1f03872ad019f507d4e35bbefa90">lwsl_hexdump()</a> - helper to hexdump a buffer (DEBUG builds only)</p>
  208. <dl class="params"><dt>Parameters</dt><dd>
  209. <table class="params">
  210. <tr><td class="paramname">buf</td><td>buffer start to dump </td></tr>
  211. <tr><td class="paramname">len</td><td>length of buffer to dump </td></tr>
  212. </table>
  213. </dd>
  214. </dl>
  215. </div>
  216. </div>
  217. <a class="anchor" id="ga42e39775c6b69b7251bdbf5a2cdd5dcd"></a>
  218. <div class="memitem">
  219. <div class="memproto">
  220. <table class="memname">
  221. <tr>
  222. <td class="memname">LWS_VISIBLE LWS_EXTERN int lwsl_timestamp </td>
  223. <td>(</td>
  224. <td class="paramtype">int&#160;</td>
  225. <td class="paramname"><em>level</em>, </td>
  226. </tr>
  227. <tr>
  228. <td class="paramkey"></td>
  229. <td></td>
  230. <td class="paramtype">char *&#160;</td>
  231. <td class="paramname"><em>p</em>, </td>
  232. </tr>
  233. <tr>
  234. <td class="paramkey"></td>
  235. <td></td>
  236. <td class="paramtype">int&#160;</td>
  237. <td class="paramname"><em>len</em>&#160;</td>
  238. </tr>
  239. <tr>
  240. <td></td>
  241. <td>)</td>
  242. <td></td><td></td>
  243. </tr>
  244. </table>
  245. </div><div class="memdoc">
  246. <p><code>#include &lt;<a class="el" href="libwebsockets_8h.html">lib/libwebsockets.h</a>&gt;</code></p>
  247. <p>lwsl_timestamp: generate logging timestamp string</p>
  248. <dl class="params"><dt>Parameters</dt><dd>
  249. <table class="params">
  250. <tr><td class="paramname">level</td><td>logging level </td></tr>
  251. <tr><td class="paramname">p</td><td>char * buffer to take timestamp </td></tr>
  252. <tr><td class="paramname">len</td><td>length of p</td></tr>
  253. </table>
  254. </dd>
  255. </dl>
  256. <p>returns length written in p </p>
  257. </div>
  258. </div>
  259. </div><!-- contents -->
  260. </div><!-- doc-content -->
  261. <!-- start footer part -->
  262. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  263. <ul>
  264. <li class="footer">Generated by
  265. <a href="http://www.doxygen.org/index.html">
  266. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  267. </ul>
  268. </div>
  269. </body>
  270. </html>