syslogs_entered = 1;
/* Send log message */
- if ( ( rc = xfer_printf ( &syslogs, "<%d>ipxe: %s\n",
- SYSLOG_PRIORITY ( SYSLOG_DEFAULT_FACILITY,
- syslogs_severity ),
- syslogs_buffer ) ) != 0 ) {
+ if ( ( rc = syslog_send ( &syslogs, syslogs_severity,
+ syslogs_buffer, "\n" ) ) != 0 ) {
DBG ( "SYSLOGS could not send log message: %s\n",
strerror ( rc ) );
}
*/
#include <stdint.h>
+#include <stdlib.h>
#include <byteswap.h>
#include <ipxe/xfer.h>
#include <ipxe/open.h>
/** The syslog UDP interface */
static struct interface syslogger = INTF_INIT ( syslogger_desc );
+/******************************************************************************
+ *
+ * Console driver
+ *
+ ******************************************************************************
+ */
+
+/** Host name (for log messages) */
+static char *syslog_hostname;
+
+/** Domain name (for log messages) */
+static char *syslog_domain;
+
+/**
+ * Transmit formatted syslog message
+ *
+ * @v xfer Data transfer interface
+ * @v severity Severity
+ * @v message Message
+ * @v terminator Message terminator
+ * @ret rc Return status code
+ */
+int syslog_send ( struct interface *xfer, unsigned int severity,
+ const char *message, const char *terminator ) {
+
+ return xfer_printf ( xfer, "<%d>%s%s%s%sipxe: %s%s",
+ SYSLOG_PRIORITY ( SYSLOG_DEFAULT_FACILITY,
+ severity ),
+ ( syslog_hostname ? syslog_hostname : "" ),
+ ( syslog_domain ? "." : "" ),
+ ( syslog_domain ? syslog_domain : "" ),
+ ( ( syslog_hostname || syslog_domain ) ? " " : ""),
+ message, terminator );
+}
+
/******************************************************************************
*
* Console driver
syslog_entered = 1;
/* Send log message */
- if ( ( rc = xfer_printf ( &syslogger, "<%d>ipxe: %s",
- SYSLOG_PRIORITY ( SYSLOG_DEFAULT_FACILITY,
- syslog_severity ),
- syslog_buffer ) ) != 0 ) {
+ if ( ( rc = syslog_send ( &syslogger, syslog_severity,
+ syslog_buffer, "" ) ) != 0 ) {
DBG ( "SYSLOG could not send log message: %s\n",
strerror ( rc ) );
}
int len;
int rc;
+ /* Fetch hostname and domain name */
+ free ( syslog_hostname );
+ if ( ( len = fetch_string_setting_copy ( NULL, &hostname_setting,
+ &syslog_hostname ) ) < 0 ) {
+ rc = len;
+ DBG ( "SYSLOG could not fetch hostname: %s\n", strerror ( rc ));
+ }
+ free ( syslog_domain );
+ if ( ( len = fetch_string_setting_copy ( NULL, &domain_setting,
+ &syslog_domain ) ) < 0 ) {
+ rc = len;
+ DBG ( "SYSLOG could not fetch domain: %s\n", strerror ( rc ) );
+ }
+
/* Fetch log server */
syslog_console.disabled = 1;
old_addr.s_addr = sin_logserver->sin_addr.s_addr;