syslog.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #ifndef _SYS_SYSLOG_H_
  2. #define _SYS_SYSLOG_H_
  3. /*
  4. * Copyright (C) 2001-2004 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. * -
  35. * Portions Copyright (c) 1982, 1986, 1988, 1993
  36. * The Regents of the University of California. All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. * 1. Redistributions of source code must retain the above copyright
  42. * notice, this list of conditions and the following disclaimer.
  43. * 2. Redistributions in binary form must reproduce the above copyright
  44. * notice, this list of conditions and the following disclaimer in the
  45. * documentation and/or other materials provided with the distribution.
  46. * 3. Neither the name of the University nor the names of its contributors
  47. * may be used to endorse or promote products derived from this software
  48. * without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  51. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  52. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  53. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  54. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  55. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  56. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  57. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  58. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  59. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  60. * SUCH DAMAGE.
  61. *
  62. */
  63. /*
  64. * $Log$
  65. * Revision 1.6 2008/08/11 07:00:28 haraldkipp
  66. * BSD types replaced by stdint types (feature request #1282721).
  67. *
  68. * Revision 1.5 2004/11/24 16:41:18 haraldkipp
  69. * Wrong prototypes for _P routines fixed
  70. *
  71. * Revision 1.4 2004/10/03 18:41:43 haraldkipp
  72. * RAM saving calls added
  73. *
  74. * Revision 1.3 2004/09/19 11:18:44 haraldkipp
  75. * Syslog client added
  76. *
  77. */
  78. /*
  79. * priorities/facilities are encoded into a single 32-bit quantity, where the
  80. * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
  81. * (0-big number). Both the priorities and the facilities map roughly
  82. * one-to-one to strings in the syslogd(8) source code. This mapping is
  83. * included in this file.
  84. *
  85. * priorities (these are ordered)
  86. */
  87. #include <sys/types.h>
  88. #include <stdint.h>
  89. #include <stdarg.h>
  90. #define LOG_EMERG 0 /* system is unusable */
  91. #define LOG_ALERT 1 /* action must be taken immediately */
  92. #define LOG_CRIT 2 /* critical conditions */
  93. #define LOG_ERR 3 /* error conditions */
  94. #define LOG_WARNING 4 /* warning conditions */
  95. #define LOG_NOTICE 5 /* normal but significant condition */
  96. #define LOG_INFO 6 /* informational */
  97. #define LOG_DEBUG 7 /* debug-level messages */
  98. #define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
  99. /* extract priority */
  100. #define LOG_PRI(p) ((p) & LOG_PRIMASK)
  101. #define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
  102. /* facility codes */
  103. #define LOG_KERN (0<<3) /* kernel messages */
  104. #define LOG_USER (1<<3) /* random user-level messages */
  105. #define LOG_MAIL (2<<3) /* mail system */
  106. #define LOG_DAEMON (3<<3) /* system daemons */
  107. #define LOG_AUTH (4<<3) /* security/authorization messages */
  108. #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
  109. #define LOG_LPR (6<<3) /* line printer subsystem */
  110. #define LOG_NEWS (7<<3) /* network news subsystem */
  111. #define LOG_UUCP (8<<3) /* UUCP subsystem */
  112. #define LOG_CRON (9<<3) /* clock daemon */
  113. #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
  114. #define LOG_FTP (11<<3) /* ftp daemon */
  115. /* other codes through 15 reserved for system use */
  116. #define LOG_LOCAL0 (16<<3) /* reserved for local use */
  117. #define LOG_LOCAL1 (17<<3) /* reserved for local use */
  118. #define LOG_LOCAL2 (18<<3) /* reserved for local use */
  119. #define LOG_LOCAL3 (19<<3) /* reserved for local use */
  120. #define LOG_LOCAL4 (20<<3) /* reserved for local use */
  121. #define LOG_LOCAL5 (21<<3) /* reserved for local use */
  122. #define LOG_LOCAL6 (22<<3) /* reserved for local use */
  123. #define LOG_LOCAL7 (23<<3) /* reserved for local use */
  124. #define LOG_NFACILITIES 24 /* current number of facilities */
  125. #define LOG_FACMASK 0x03f8 /* mask to extract facility part */
  126. /* facility of pri */
  127. #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
  128. #define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */
  129. /*
  130. * arguments to setlogmask.
  131. */
  132. #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
  133. #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
  134. /*
  135. * Option flags for openlog.
  136. *
  137. * LOG_ODELAY no longer does anything.
  138. * LOG_NDELAY is the inverse of what it used to be.
  139. */
  140. #define LOG_PID 0x01 /* log the pid with each message */
  141. #define LOG_CONS 0x02 /* log on the console if errors in sending */
  142. #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
  143. #define LOG_NDELAY 0x08 /* don't delay open */
  144. #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
  145. #define LOG_PERROR 0x20 /* log to stderr as well */
  146. #ifdef SYSLOG_INTERNAL
  147. #ifndef SYSLOG_MAXBUF
  148. /*!
  149. * \brief Syslog message buffer size.
  150. */
  151. #define SYSLOG_MAXBUF 256
  152. #endif
  153. extern char *syslog_buf;
  154. #endif /* SYSLOG_INTERNAL */
  155. extern void closelog(void);
  156. extern void openlog(const char *, int, int);
  157. extern int setlogmask(int);
  158. extern uint32_t setlogserver(uint32_t ip, uint16_t port);
  159. extern void syslog(int, const char *, ...);
  160. extern void vsyslog(int, const char *, va_list);
  161. #ifdef __HARVARD_ARCH__
  162. #ifdef SYSLOG_INTERNAL
  163. extern size_t syslog_header(int pri);
  164. extern void syslog_flush(size_t len);
  165. #endif
  166. extern void syslog_P(int pri, PGM_P fmt, ...);
  167. extern void vsyslog_P(int pri, PGM_P fmt, va_list ap);
  168. #else
  169. #define syslog_P syslog
  170. #define vsyslog_P vsyslog
  171. #endif
  172. #endif