syslog.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-09-07 armink the first version
  9. */
  10. #ifndef _SYSLOG_H_
  11. #define _SYSLOG_H_
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /*
  16. * priorities/facilities are encoded into a single 32-bit quantity, where the
  17. * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
  18. * (0-big number). Both the priorities and the facilities map roughly
  19. * one-to-one to strings in the syslogd(8) source code. This mapping is
  20. * included in this file.
  21. *
  22. * priorities (these are ordered)
  23. */
  24. #define LOG_EMERG 0 /* system is unusable */
  25. #define LOG_ALERT 1 /* action must be taken immediately */
  26. #define LOG_CRIT 2 /* critical conditions */
  27. #define LOG_ERR 3 /* error conditions */
  28. #define LOG_WARNING 4 /* warning conditions */
  29. #define LOG_NOTICE 5 /* normal but significant condition */
  30. #define LOG_INFO 6 /* informational */
  31. #define LOG_DEBUG 7 /* debug-level messages */
  32. #define LOG_PRIMASK 0x07
  33. #define LOG_PRI(p) ((p) & LOG_PRIMASK)
  34. #define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
  35. /* facility codes */
  36. #define LOG_KERN (0<<3) /* kernel messages */
  37. #define LOG_USER (1<<3) /* random user-level messages */
  38. #define LOG_MAIL (2<<3) /* mail system */
  39. #define LOG_DAEMON (3<<3) /* system daemons */
  40. #define LOG_AUTH (4<<3) /* security/authorization messages */
  41. #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
  42. #define LOG_LPR (6<<3) /* line printer subsystem */
  43. #define LOG_NEWS (7<<3) /* network news subsystem */
  44. #define LOG_UUCP (8<<3) /* UUCP subsystem */
  45. #define LOG_CRON (9<<3) /* clock daemon */
  46. #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
  47. /* other codes through 15 reserved for system use */
  48. #define LOG_LOCAL0 (16<<3) /* reserved for local use */
  49. #define LOG_LOCAL1 (17<<3) /* reserved for local use */
  50. #define LOG_LOCAL2 (18<<3) /* reserved for local use */
  51. #define LOG_LOCAL3 (19<<3) /* reserved for local use */
  52. #define LOG_LOCAL4 (20<<3) /* reserved for local use */
  53. #define LOG_LOCAL5 (21<<3) /* reserved for local use */
  54. #define LOG_LOCAL6 (22<<3) /* reserved for local use */
  55. #define LOG_LOCAL7 (23<<3) /* reserved for local use */
  56. #define LOG_NFACILITIES 24 /* current number of facilities */
  57. #define LOG_FACMASK 0x03f8 /* mask to extract facility part */
  58. /* facility of pri */
  59. #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
  60. /*
  61. * arguments to setlogmask.
  62. */
  63. #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
  64. #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
  65. /*
  66. * Option flags for openlog.
  67. *
  68. * LOG_ODELAY no longer does anything.
  69. * LOG_NDELAY is the inverse of what it used to be.
  70. */
  71. #define LOG_PID 0x01 /* log the pid with each message */
  72. #define LOG_CONS 0x02 /* log on the console if errors in sending */
  73. #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
  74. #define LOG_NDELAY 0x08 /* don't delay open */
  75. #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
  76. #define LOG_PERROR 0x20 /* log to stderr as well */
  77. #include <stdarg.h>
  78. void closelog(void);
  79. void openlog(const char *ident, int option, int facility);
  80. int setlogmask(int mask);
  81. void syslog(int priority, const char *format, ...);
  82. void vsyslog(int priority, const char *format, va_list args);
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif /* _SYSLOG_H_ */