[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>
This commit is contained in:
Michael Brown
2012-03-26 20:23:30 +01:00
parent c2875ae329
commit 3ff7927d2f
4 changed files with 53 additions and 14 deletions

View File

@@ -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 ) );