|
|
@@ -10,6 +10,7 @@
|
|
10
|
10
|
FILE_LICENCE ( GPL2_OR_LATER );
|
|
11
|
11
|
|
|
12
|
12
|
#include <stdarg.h>
|
|
|
13
|
+#include <ipxe/ansiesc.h>
|
|
13
|
14
|
#include <config/console.h>
|
|
14
|
15
|
|
|
15
|
16
|
/**
|
|
|
@@ -55,6 +56,16 @@ extern void log_vprintf ( const char *fmt, va_list args );
|
|
55
|
56
|
extern void __attribute__ (( format ( printf, 1, 2 ) ))
|
|
56
|
57
|
log_printf ( const char *fmt, ... );
|
|
57
|
58
|
|
|
|
59
|
+/** ANSI private escape sequence to set syslog priority
|
|
|
60
|
+ *
|
|
|
61
|
+ * @v priority Priority
|
|
|
62
|
+ */
|
|
|
63
|
+#define SYSLOG_SET_PRIORITY( priority ) \
|
|
|
64
|
+ "\033[" #priority "p"
|
|
|
65
|
+
|
|
|
66
|
+/** ANSI private escape sequence to clear syslog priority */
|
|
|
67
|
+#define SYSLOG_CLEAR_PRIORITY "\033[p"
|
|
|
68
|
+
|
|
58
|
69
|
/**
|
|
59
|
70
|
* Write message to system log
|
|
60
|
71
|
*
|
|
|
@@ -62,10 +73,11 @@ log_printf ( const char *fmt, ... );
|
|
62
|
73
|
* @v fmt Format string
|
|
63
|
74
|
* @v ... Arguments
|
|
64
|
75
|
*/
|
|
65
|
|
-#define vsyslog( priority, fmt, args ) do { \
|
|
66
|
|
- if ( (priority) <= LOG_LEVEL ) { \
|
|
67
|
|
- log_vprintf ( fmt, (args) ); \
|
|
68
|
|
- } \
|
|
|
76
|
+#define vsyslog( priority, fmt, args ) do { \
|
|
|
77
|
+ if ( (priority) <= LOG_LEVEL ) { \
|
|
|
78
|
+ log_vprintf ( SYSLOG_SET_PRIORITY ( priority ) fmt \
|
|
|
79
|
+ SYSLOG_CLEAR_PRIORITY, (args) ); \
|
|
|
80
|
+ } \
|
|
69
|
81
|
} while ( 0 )
|
|
70
|
82
|
|
|
71
|
83
|
/**
|
|
|
@@ -75,10 +87,11 @@ log_printf ( const char *fmt, ... );
|
|
75
|
87
|
* @v fmt Format string
|
|
76
|
88
|
* @v ... Arguments
|
|
77
|
89
|
*/
|
|
78
|
|
-#define syslog( priority, fmt, ... ) do { \
|
|
79
|
|
- if ( (priority) <= LOG_LEVEL ) { \
|
|
80
|
|
- log_printf ( fmt, ##__VA_ARGS__ ); \
|
|
81
|
|
- } \
|
|
|
90
|
+#define syslog( priority, fmt, ... ) do { \
|
|
|
91
|
+ if ( (priority) <= LOG_LEVEL ) { \
|
|
|
92
|
+ log_printf ( SYSLOG_SET_PRIORITY ( priority ) fmt \
|
|
|
93
|
+ SYSLOG_CLEAR_PRIORITY, ##__VA_ARGS__ ); \
|
|
|
94
|
+ } \
|
|
82
|
95
|
} while ( 0 )
|
|
83
|
96
|
|
|
84
|
97
|
#endif /* _SYSLOG_H */
|