Esempio n. 1
0
/**
 * Print a character to syslog console
 *
 * @v character		Character to be printed
 */
static void syslog_putchar ( int character ) {
	int rc;

	/* Ignore if we are already mid-logging */
	if ( syslog_entered )
		return;

	/* Fill line buffer */
	if ( line_putchar ( &syslog_line, character ) == 0 )
		return;

	/* Guard against re-entry */
	syslog_entered = 1;

	/* Send log message */
	if ( ( rc = xfer_printf ( &syslogger, "<%d>ipxe: %s",
				  SYSLOG_PRIORITY ( SYSLOG_FACILITY,
						    SYSLOG_SEVERITY ),
				  syslog_buffer ) ) != 0 ) {
		DBG ( "SYSLOG could not send log message: %s\n",
		      strerror ( rc ) );
	}

	/* Clear re-entry flag */
	syslog_entered = 0;
}
Esempio n. 2
0
File: syslog.c Progetto: 3a9LL/panda
/**
 * Print a character to syslog console
 *
 * @v character		Character to be printed
 */
static void syslog_putchar ( int character ) {
	int rc;

	/* Do nothing if we have no log server */
	if ( ! logserver.st_family )
		return;

	/* Ignore if we are already mid-logging */
	if ( syslog_entered )
		return;

	/* Strip ANSI escape sequences */
	character = ansiesc_process ( &syslog_ansiesc_ctx, character );
	if ( character < 0 )
		return;

	/* Ignore carriage return */
	if ( character == '\r' )
		return;

	/* Treat newline as a terminator */
	if ( character == '\n' )
		character = 0;

	/* Add character to buffer */
	syslog_buffer[syslog_idx++] = character;

	/* Do nothing more unless we reach end-of-line (or end-of-buffer) */
	if ( ( character != 0 ) &&
	     ( syslog_idx < ( sizeof ( syslog_buffer ) - 1 /* NUL */ ) ) ) {
		return;
	}

	/* Reset to start of buffer */
	syslog_idx = 0;

	/* Guard against re-entry */
	syslog_entered = 1;

	/* Send log message */
	if ( ( rc = xfer_printf ( &syslogger, "<%d>ipxe: %s",
				  SYSLOG_PRIORITY ( SYSLOG_FACILITY,
						    SYSLOG_SEVERITY ),
				  syslog_buffer ) ) != 0 ) {
		DBG ( "SYSLOG could not send log message: %s\n",
		      strerror ( rc ) );
	}

	/* Clear re-entry flag */
	syslog_entered = 0;
}