summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ipxe/ansiesc.h7
-rw-r--r--src/include/ipxe/syslog.h8
-rw-r--r--src/include/syslog.h29
3 files changed, 32 insertions, 12 deletions
diff --git a/src/include/ipxe/ansiesc.h b/src/include/ipxe/ansiesc.h
index 35438e43a..c00af258a 100644
--- a/src/include/ipxe/ansiesc.h
+++ b/src/include/ipxe/ansiesc.h
@@ -113,6 +113,13 @@ struct ansiesc_context {
/** Select graphic rendition */
#define ANSIESC_SGR 'm'
+/** Explicit log message priority
+ *
+ * This is an iPXE private sequence identifier. (The range 'p' to '~'
+ * is reserved for private sequences.)
+ */
+#define ANSIESC_LOG_PRIORITY 'p'
+
/** @} */
extern int ansiesc_process ( struct ansiesc_context *ctx, int c );
diff --git a/src/include/ipxe/syslog.h b/src/include/ipxe/syslog.h
index 256ac7613..035ca6700 100644
--- a/src/include/ipxe/syslog.h
+++ b/src/include/ipxe/syslog.h
@@ -20,17 +20,17 @@ FILE_LICENCE ( GPL2_OR_LATER );
*/
#define SYSLOG_BUFSIZE 128
-/** Syslog facility
+/** Syslog default facility
*
* This is a policy decision
*/
-#define SYSLOG_FACILITY 0 /* kernel */
+#define SYSLOG_DEFAULT_FACILITY 0 /* kernel */
-/** Syslog severity
+/** Syslog default severity
*
* This is a policy decision
*/
-#define SYSLOG_SEVERITY LOG_INFO
+#define SYSLOG_DEFAULT_SEVERITY LOG_INFO
/** Syslog priority */
#define SYSLOG_PRIORITY( facility, severity ) ( 8 * (facility) + (severity) )
diff --git a/src/include/syslog.h b/src/include/syslog.h
index cc7b19fd5..3dfc11b96 100644
--- a/src/include/syslog.h
+++ b/src/include/syslog.h
@@ -10,6 +10,7 @@
FILE_LICENCE ( GPL2_OR_LATER );
#include <stdarg.h>
+#include <ipxe/ansiesc.h>
#include <config/console.h>
/**
@@ -55,6 +56,16 @@ extern void log_vprintf ( const char *fmt, va_list args );
extern void __attribute__ (( format ( printf, 1, 2 ) ))
log_printf ( const char *fmt, ... );
+/** ANSI private escape sequence to set syslog priority
+ *
+ * @v priority Priority
+ */
+#define SYSLOG_SET_PRIORITY( priority ) \
+ "\033[" #priority "p"
+
+/** ANSI private escape sequence to clear syslog priority */
+#define SYSLOG_CLEAR_PRIORITY "\033[p"
+
/**
* Write message to system log
*
@@ -62,10 +73,11 @@ log_printf ( const char *fmt, ... );
* @v fmt Format string
* @v ... Arguments
*/
-#define vsyslog( priority, fmt, args ) do { \
- if ( (priority) <= LOG_LEVEL ) { \
- log_vprintf ( fmt, (args) ); \
- } \
+#define vsyslog( priority, fmt, args ) do { \
+ if ( (priority) <= LOG_LEVEL ) { \
+ log_vprintf ( SYSLOG_SET_PRIORITY ( priority ) fmt \
+ SYSLOG_CLEAR_PRIORITY, (args) ); \
+ } \
} while ( 0 )
/**
@@ -75,10 +87,11 @@ log_printf ( const char *fmt, ... );
* @v fmt Format string
* @v ... Arguments
*/
-#define syslog( priority, fmt, ... ) do { \
- if ( (priority) <= LOG_LEVEL ) { \
- log_printf ( fmt, ##__VA_ARGS__ ); \
- } \
+#define syslog( priority, fmt, ... ) do { \
+ if ( (priority) <= LOG_LEVEL ) { \
+ log_printf ( SYSLOG_SET_PRIORITY ( priority ) fmt \
+ SYSLOG_CLEAR_PRIORITY, ##__VA_ARGS__ ); \
+ } \
} while ( 0 )
#endif /* _SYSLOG_H */