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