diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/ipxe/console.h | 7 | ||||
| -rw-r--r-- | src/include/ipxe/syslog.h | 4 | ||||
| -rw-r--r-- | src/include/syslog.h | 84 |
3 files changed, 92 insertions, 3 deletions
diff --git a/src/include/ipxe/console.h b/src/include/ipxe/console.h index 5ff93884d..e2bf4be97 100644 --- a/src/include/ipxe/console.h +++ b/src/include/ipxe/console.h @@ -120,9 +120,12 @@ struct console_driver { /** Text-based user interface */ #define CONSOLE_USAGE_TUI 0x0004 +/** Log messages */ +#define CONSOLE_USAGE_LOG 0x0008 + /** All console usages */ -#define CONSOLE_USAGE_ALL \ - ( CONSOLE_USAGE_STDOUT | CONSOLE_USAGE_DEBUG | CONSOLE_USAGE_TUI ) +#define CONSOLE_USAGE_ALL ( CONSOLE_USAGE_STDOUT | CONSOLE_USAGE_DEBUG | \ + CONSOLE_USAGE_TUI | CONSOLE_USAGE_LOG ) /** @} */ diff --git a/src/include/ipxe/syslog.h b/src/include/ipxe/syslog.h index 25edc6b0c..256ac7613 100644 --- a/src/include/ipxe/syslog.h +++ b/src/include/ipxe/syslog.h @@ -9,6 +9,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); +#include <syslog.h> + /** Syslog server port */ #define SYSLOG_PORT 514 @@ -28,7 +30,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); * * This is a policy decision */ -#define SYSLOG_SEVERITY 6 /* informational */ +#define SYSLOG_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 new file mode 100644 index 000000000..cc7b19fd5 --- /dev/null +++ b/src/include/syslog.h @@ -0,0 +1,84 @@ +#ifndef _SYSLOG_H +#define _SYSLOG_H + +/** @file + * + * System logger + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#include <stdarg.h> +#include <config/console.h> + +/** + * @defgroup syslogpri Syslog priorities + * + * These values are chosen to match those used in the syslog network + * protocol (RFC 5424). + * + * @{ + */ + +/** Emergency: system is unusable */ +#define LOG_EMERG 0 + +/** Alert: action must be taken immediately */ +#define LOG_ALERT 1 + +/** Critical: critical conditions */ +#define LOG_CRIT 2 + +/** Error: error conditions */ +#define LOG_ERR 3 + +/** Warning: warning conditions */ +#define LOG_WARNING 4 + +/** Notice: normal but significant conditions */ +#define LOG_NOTICE 5 + +/** Informational: informational messages */ +#define LOG_INFO 6 + +/** Debug: debug-level messages */ +#define LOG_DEBUG 7 + +/** @} */ + +/** Do not log any messages */ +#define LOG_NONE -1 + +extern void log_vprintf ( const char *fmt, va_list args ); + +extern void __attribute__ (( format ( printf, 1, 2 ) )) +log_printf ( const char *fmt, ... ); + +/** + * Write message to system log + * + * @v priority Message priority + * @v fmt Format string + * @v ... Arguments + */ +#define vsyslog( priority, fmt, args ) do { \ + if ( (priority) <= LOG_LEVEL ) { \ + log_vprintf ( fmt, (args) ); \ + } \ + } while ( 0 ) + +/** + * Write message to system log + * + * @v priority Message priority + * @v fmt Format string + * @v ... Arguments + */ +#define syslog( priority, fmt, ... ) do { \ + if ( (priority) <= LOG_LEVEL ) { \ + log_printf ( fmt, ##__VA_ARGS__ ); \ + } \ + } while ( 0 ) + +#endif /* _SYSLOG_H */ |
