You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

297 lines
11 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: pantheios/backends/bec.syslog.h
  3. *
  4. * Purpose: Declaration of the Pantheios syslog Stock Back-end API.
  5. *
  6. * Created: 23rd July 2005
  7. * Updated: 30th April 2010
  8. *
  9. * Home: http://www.pantheios.org/
  10. *
  11. * Copyright (c) 2005-2010, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are
  16. * met:
  17. *
  18. * - Redistributions of source code must retain the above copyright notice,
  19. * this list of conditions and the following disclaimer.
  20. * - Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
  24. * names of any contributors may be used to endorse or promote products
  25. * derived from this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  28. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  29. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  30. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  31. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  32. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  33. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  34. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  35. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  36. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  37. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. * ////////////////////////////////////////////////////////////////////// */
  40. /** \file pantheios/backends/bec.syslog.h
  41. *
  42. * [C, C++] Pantheios SysLog Back-end Common API
  43. */
  44. #ifndef PANTHEIOS_INCL_PANTHEIOS_BACKENDS_H_SYSLOG_SRC
  45. #define PANTHEIOS_INCL_PANTHEIOS_BACKENDS_H_SYSLOG_SRC
  46. /* /////////////////////////////////////////////////////////////////////////
  47. * Version information
  48. */
  49. #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
  50. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_SYSLOG_MAJOR 3
  51. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_SYSLOG_MINOR 1
  52. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_SYSLOG_REVISION 1
  53. # define PANTHEIOS_VER_PANTHEIOS_BACKENDS_H_BEC_SYSLOG_EDIT 22
  54. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
  55. /* /////////////////////////////////////////////////////////////////////////
  56. * Includes
  57. */
  58. #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
  59. # include <pantheios/pantheios.h>
  60. #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
  61. #ifndef PANTHEIOS_INCL_PANTHEIOS_H_BACKEND
  62. # include <pantheios/backend.h>
  63. #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_BACKEND */
  64. /* /////////////////////////////////////////////////////////////////////////
  65. * Documentation
  66. */
  67. /** \defgroup group__backend__stock_backends__syslog Pantheios UNIX SysLog Stock Back-end
  68. * \ingroup group__backend__stock_backends
  69. * Back-end library built on top of the UNIX <b>syslog</b> API.
  70. */
  71. /* /////////////////////////////////////////////////////////////////////////
  72. * Typedefs
  73. */
  74. /** \defgroup group__backend__stock_backends__syslog__flags Pantheios UNIX syslog Stock Back-end Flags
  75. * \ingroup group__backend__stock_backends__syslog
  76. * Flags for the \ref group__backend__stock_backends__syslog
  77. *
  78. * These flags are passed as the <code>options</code> parameter to the
  79. * SysLog API function <code>openlog()</code> during back-end
  80. * initialisation.
  81. */
  82. /** \def PANTHEIOS_BE_SYSLOG_F_PERROR
  83. * Causes the \ref group__backend__stock_backends__syslog to
  84. * write to the calling process' standard error, in addition to submitting
  85. * it to SysLog.
  86. * \ingroup group__backend__stock_backends__syslog__flags
  87. *
  88. * Specifying this flag causes the pan_be_syslog_init_t::options member to
  89. * contain the SysLog <code>LOG_PERROR</code> flag.
  90. *
  91. * \note On operating systems on which this non-standard feature is not
  92. * available as part of the Syslog API, this will be provided by a
  93. * distinct call to fprintf(stderr).
  94. */
  95. #define PANTHEIOS_BE_SYSLOG_F_PERROR (0x00100000)
  96. /** \def PANTHEIOS_BE_SYSLOG_F_CONS
  97. * Causes the \ref group__backend__stock_backends__syslog to
  98. * write any message that fails to be submitted to SysLog to the system
  99. * console.
  100. * \ingroup group__backend__stock_backends__syslog__flags
  101. *
  102. * Specifying this flag causes the pan_be_syslog_init_t::options member to
  103. * contain the SysLog <code>LOG_CONS</code> flag.
  104. */
  105. #define PANTHEIOS_BE_SYSLOG_F_CONS (0x00200000)
  106. /** \def PANTHEIOS_BE_SYSLOG_F_PID
  107. * Causes the \ref group__backend__stock_backends__syslog to include
  108. * the process Id in the statement.
  109. * \ingroup group__backend__stock_backends__syslog__flags
  110. *
  111. * Specifying this flag causes the pan_be_syslog_init_t::options member to
  112. * contain the SysLog <code>LOG_PID</code> flag.
  113. */
  114. #define PANTHEIOS_BE_SYSLOG_F_PID (0x00400000)
  115. /** \def PANTHEIOS_BE_SYSLOG_F_NDELAY
  116. * Causes the \ref group__backend__stock_backends__syslog to
  117. * connect to the syslog socket immediately, rather than on the first call
  118. * to <code>syslog()</code>.
  119. * \ingroup group__backend__stock_backends__syslog__flags
  120. *
  121. * Specifying this flag causes the pan_be_syslog_init_t::options member to
  122. * contain the SysLog <code>LOG_NDELAY</code> flag.
  123. */
  124. #define PANTHEIOS_BE_SYSLOG_F_NDELAY (0x00800000)
  125. /** Structure used for specifying initialisation information to the
  126. * be.syslog library.
  127. * \ingroup group__backend__stock_backends__syslog
  128. */
  129. struct pan_be_syslog_init_t
  130. {
  131. #if !defined(PANTHEIOS_DOCUMENTATION_SKIP_SECTION) && \
  132. !defined(PANTHEIOS_NO_NAMESPACE)
  133. typedef pantheios::pan_uint8_t pan_uint8_t;
  134. typedef pantheios::pan_uint16_t pan_uint16_t;
  135. typedef pantheios::pan_uint32_t pan_uint32_t;
  136. #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION && !PANTHEIOS_NO_NAMESPACE */
  137. pan_uint32_t version; /*!< Must be initialised to the value of PANTHEIOS_VER */
  138. pan_uint32_t flags; /*!< \ref group__backend__stock_backends__syslog__flags "Flags" that control the information displayed. */
  139. pan_uint32_t options; /*!< Options passed to <code>openlog()</code>. Will be overridden by \link pan_be_syslog_init_t::flags flags\endlink. */
  140. pan_uint8_t facility; /*!< The facility used by the process. Must be <= 124. Defaults to LOG_USER */
  141. #ifdef __cplusplus
  142. public: /* Construction */
  143. # ifndef PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT
  144. pan_be_syslog_init_t();
  145. # endif /* !PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT */
  146. #endif /* __cplusplus */
  147. };
  148. #if !defined(__cplusplus)
  149. typedef struct pan_be_syslog_init_t pan_be_syslog_init_t;
  150. #endif /* !__cplusplus */
  151. /* /////////////////////////////////////////////////////////////////////////
  152. * Application-defined functions
  153. */
  154. /** \ref page__backend__callbacks "Callback" function defined by
  155. * the application, invoked when the
  156. * API is initialised with a NULL <code>init</code> parameter.
  157. * \ingroup group__backend__stock_backends__syslog
  158. *
  159. * \note This function is only required when the
  160. * \ref page__backend__callbacks "callback" version of the library is
  161. * used.
  162. */
  163. PANTHEIOS_CALL(void) pantheios_be_syslog_getAppInit(
  164. int backEndId
  165. , pan_be_syslog_init_t* init
  166. ) /* throw() */;
  167. /* /////////////////////////////////////////////////////////////////////////
  168. * API
  169. */
  170. /** Fills out a copy of the initialisation structure with default
  171. * values (representative of the default behaviour of the library),
  172. * ready to be customised and passed to the API initialiser function
  173. * pantheios_be_syslog_init().
  174. * \ingroup group__backend__stock_backends__syslog
  175. *
  176. * \note This function should <b>not</b> be called on an
  177. * already-initialised instance, as is the case in the implementation
  178. * of the pantheios_be_syslog_getAppInit() function, as it will
  179. * already have been called by pantheios_be_syslog_init() prior
  180. * to the callback.
  181. */
  182. PANTHEIOS_CALL(void) pantheios_be_syslog_getDefaultAppInit(
  183. pan_be_syslog_init_t* init
  184. ) /* throw() */;
  185. /** Implements the functionality for pantheios_be_init() over the UNIX SysLog API.
  186. * \ingroup group__backend__stock_backends__syslog
  187. */
  188. PANTHEIOS_CALL(int) pantheios_be_syslog_init(
  189. PAN_CHAR_T const* processIdentity
  190. , int id
  191. , pan_be_syslog_init_t const* init
  192. , void* reserved
  193. , void** ptoken
  194. );
  195. /** Implements the functionality for pantheios_be_uninit() over the UNIX SysLog API.
  196. * \ingroup group__backend__stock_backends__syslog
  197. */
  198. PANTHEIOS_CALL(void) pantheios_be_syslog_uninit(
  199. void* token
  200. );
  201. /** Implements the functionality for pantheios_be_logEntry() over the UNIX SysLog API.
  202. * \ingroup group__backend__stock_backends__syslog
  203. */
  204. PANTHEIOS_CALL(int) pantheios_be_syslog_logEntry(
  205. void* feToken
  206. , void* beToken
  207. , int severity
  208. , PAN_CHAR_T const* entry
  209. , size_t cchEntry
  210. );
  211. /** Parses the be.syslog back-end flags
  212. *
  213. * \ingroup group__backend
  214. *
  215. * Processes an argument list in the same way as
  216. * pantheios_be_parseStockArgs(), filling out the
  217. * pan_be_COMErrorObject_init_t in accordance with the arguments
  218. * found.
  219. *
  220. * Recognises the following standard argument names:
  221. * - "showProcessId" (Boolean)
  222. * - "showTime" (Boolean)
  223. * - "showSeverity" (Boolean)
  224. * - "useSystemTime" (Boolean)
  225. * - "showDetailsAtStart" (Boolean)
  226. * - "useUnixFormat" (Boolean)
  227. * - "showDate" (Boolean)
  228. * - "showTime" (Boolean)
  229. * - "highResolution" (Boolean)
  230. * - "lowResolution" (Boolean)
  231. *
  232. * Recognises the following back-end specific argument names:
  233. * - "useStderr" (Boolean)
  234. * - "useConsole" (Boolean)
  235. * - "showPid" (Boolean)
  236. * - "connectImmediately" (Boolean)
  237. */
  238. PANTHEIOS_CALL(int) pantheios_be_syslog_parseArgs(
  239. size_t numArgs
  240. #ifdef PANTHEIOS_NO_NAMESPACE
  241. , struct pan_slice_t* const args
  242. #else /* ? PANTHEIOS_NO_NAMESPACE */
  243. , pantheios::pan_slice_t* const args
  244. #endif /* PANTHEIOS_NO_NAMESPACE */
  245. , pan_be_syslog_init_t* init
  246. );
  247. /* ////////////////////////////////////////////////////////////////////// */
  248. #ifdef __cplusplus
  249. # ifndef PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT
  250. inline pan_be_syslog_init_t::pan_be_syslog_init_t()
  251. {
  252. pantheios_be_syslog_getDefaultAppInit(this);
  253. }
  254. # endif /* !PANTHEIOS_BE_INIT_NO_CPP_STRUCT_INIT */
  255. #endif /* __cplusplus */
  256. /* ////////////////////////////////////////////////////////////////////// */
  257. #endif /* PANTHEIOS_INCL_PANTHEIOS_BACKENDS_H_SYSLOG_SRC */
  258. /* ///////////////////////////// end of file //////////////////////////// */