Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

syslog.h 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef _SYSLOG_H
  2. #define _SYSLOG_H
  3. /** @file
  4. *
  5. * System logger
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <stdarg.h>
  10. #include <ipxe/ansiesc.h>
  11. #include <config/console.h>
  12. /**
  13. * @defgroup syslogpri Syslog priorities
  14. *
  15. * These values are chosen to match those used in the syslog network
  16. * protocol (RFC 5424).
  17. *
  18. * @{
  19. */
  20. /** Emergency: system is unusable */
  21. #define LOG_EMERG 0
  22. /** Alert: action must be taken immediately */
  23. #define LOG_ALERT 1
  24. /** Critical: critical conditions */
  25. #define LOG_CRIT 2
  26. /** Error: error conditions */
  27. #define LOG_ERR 3
  28. /** Warning: warning conditions */
  29. #define LOG_WARNING 4
  30. /** Notice: normal but significant conditions */
  31. #define LOG_NOTICE 5
  32. /** Informational: informational messages */
  33. #define LOG_INFO 6
  34. /** Debug: debug-level messages */
  35. #define LOG_DEBUG 7
  36. /** @} */
  37. /** Do not log any messages */
  38. #define LOG_NONE -1
  39. /** Log all messages */
  40. #define LOG_ALL LOG_DEBUG
  41. extern void log_vprintf ( const char *fmt, va_list args );
  42. extern void __attribute__ (( format ( printf, 1, 2 ) ))
  43. log_printf ( const char *fmt, ... );
  44. /** ANSI private escape sequence to set syslog priority
  45. *
  46. * @v priority Priority
  47. */
  48. #define SYSLOG_SET_PRIORITY( priority ) \
  49. "\033[" #priority "p"
  50. /** ANSI private escape sequence to clear syslog priority */
  51. #define SYSLOG_CLEAR_PRIORITY "\033[p"
  52. /**
  53. * Write message to system log
  54. *
  55. * @v priority Message priority
  56. * @v fmt Format string
  57. * @v ... Arguments
  58. */
  59. #define vsyslog( priority, fmt, args ) do { \
  60. if ( (priority) <= LOG_LEVEL ) { \
  61. log_vprintf ( SYSLOG_SET_PRIORITY ( priority ) fmt \
  62. SYSLOG_CLEAR_PRIORITY, (args) ); \
  63. } \
  64. } while ( 0 )
  65. /**
  66. * Write message to system log
  67. *
  68. * @v priority Message priority
  69. * @v fmt Format string
  70. * @v ... Arguments
  71. */
  72. #define syslog( priority, fmt, ... ) do { \
  73. if ( (priority) <= LOG_LEVEL ) { \
  74. log_printf ( SYSLOG_SET_PRIORITY ( priority ) fmt \
  75. SYSLOG_CLEAR_PRIORITY, ##__VA_ARGS__ ); \
  76. } \
  77. } while ( 0 )
  78. #endif /* _SYSLOG_H */