diff options
author | Michael Brown | 2012-03-26 21:23:30 +0200 |
---|---|---|
committer | Michael Brown | 2012-03-26 22:58:58 +0200 |
commit | 3ff7927d2fd15dd0a524f27d714dff667511718a (patch) | |
tree | 2fd8f8fc92d35946afcc0aeb13c392a49c4efd64 /src/net/udp/syslog.c | |
parent | [console] Do not share ANSI escape context between lineconsole users (diff) | |
download | ipxe-3ff7927d2fd15dd0a524f27d714dff667511718a.tar.gz ipxe-3ff7927d2fd15dd0a524f27d714dff667511718a.tar.xz ipxe-3ff7927d2fd15dd0a524f27d714dff667511718a.zip |
[syslog] Pass internal syslog() priority through to syslog console
Use a private ANSI escape sequence to convey the priority of an
internal syslog() message through to the syslog server.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/udp/syslog.c')
-rw-r--r-- | src/net/udp/syslog.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/net/udp/syslog.c b/src/net/udp/syslog.c index caa0d0b2..4a265314 100644 --- a/src/net/udp/syslog.c +++ b/src/net/udp/syslog.c @@ -68,8 +68,27 @@ static struct interface syslogger = INTF_INIT ( syslogger_desc ); /** Syslog line buffer */ static char syslog_buffer[SYSLOG_BUFSIZE]; +/** Syslog severity */ +static unsigned int syslog_severity = SYSLOG_DEFAULT_SEVERITY; + +/** + * Handle ANSI set syslog priority (private sequence) + * + * @v count Parameter count + * @v params List of graphic rendition aspects + */ +static void syslog_handle_priority ( unsigned int count __unused, + int params[] ) { + if ( params[0] >= 0 ) { + syslog_severity = params[0]; + } else { + syslog_severity = SYSLOG_DEFAULT_SEVERITY; + } +} + /** Syslog ANSI escape sequence handlers */ static struct ansiesc_handler syslog_handlers[] = { + { ANSIESC_LOG_PRIORITY, syslog_handle_priority }, { 0, NULL } }; @@ -106,8 +125,8 @@ static void syslog_putchar ( int character ) { /* Send log message */ if ( ( rc = xfer_printf ( &syslogger, "<%d>ipxe: %s", - SYSLOG_PRIORITY ( SYSLOG_FACILITY, - SYSLOG_SEVERITY ), + SYSLOG_PRIORITY ( SYSLOG_DEFAULT_FACILITY, + syslog_severity ), syslog_buffer ) ) != 0 ) { DBG ( "SYSLOG could not send log message: %s\n", strerror ( rc ) ); |