Nut/OS  4.10.3
API Reference
syslog

Syslog protocol support. More...

Collaboration diagram for syslog:

Functions

size_t syslog_header (int pri)
 Assemble syslog header.
void syslog_flush (size_t len)
 Send syslog buffer.
void vsyslog (int pri, CONST char *fmt, va_list ap)
 Print log message.
void syslog (int pri, CONST char *fmt,...)
 Print log message.
int setlogmask (int logmask)
 Set the log priority mask level.
uint32_t setlogserver (uint32_t ip, uint16_t port)
 Set the log server's IP address.
void openlog (CONST char *ident, int logstat, int logfac)
 Open logging for specialized processing.
void closelog (void)
 Release system resources occupied by syslog().
void vsyslog_P (int pri, PGM_P fmt_P, va_list ap)
 Print log message.
void syslog_P (int pri, PGM_P fmt_P,...)
 Print log message.

Variables

char * syslog_buf

Detailed Description

Syslog protocol support.


Function Documentation

size_t syslog_header ( int  pri)

Assemble syslog header.

For internal use only.

Parameters:
priValue of the syslog PRI part.
Returns:
Number of characters in the global syslog buffer.

Definition at line 138 of file syslog.c.

References _CONFNET::cdn_cip_addr, _CONFNET::cdn_ip_addr, confnet, confos, gmtime(), _CONFOS::hostname, inet_ntoa(), localtime(), LOG_FACMASK, LOG_MASK, LOG_NDELAY, LOG_PRI, LOG_PRIMASK, openlog(), sprintf, strcpy(), strlen(), syslog_buf, time(), _tm::tm_hour, _tm::tm_mday, _tm::tm_min, _tm::tm_mon, _tm::tm_sec, and _tm::tm_year.

Referenced by vsyslog(), and vsyslog_P().

Here is the call graph for this function:

void syslog_flush ( size_t  len)

Send syslog buffer.

For internal use only.

Parameters:
lenNumber of valid characters in buffer.

Definition at line 270 of file syslog.c.

References _fileno(), _write(), LOG_PERROR, NutUdpSendTo(), stderr, and syslog_buf.

Referenced by vsyslog(), and vsyslog_P().

Here is the call graph for this function:

void vsyslog ( int  pri,
CONST char *  fmt,
va_list  ap 
)

Print log message.

Alternate form of syslog(), in which the arguments have already been captured using the variable-length argument facilities.

Parameters:
priPriority level of this message. See syslog().
fmtFormat string containing conversion specifications like printf.
apList of arguments.

Definition at line 295 of file syslog.c.

References fputc(), fputs(), puts, stderr, strlen(), syslog_buf, syslog_flush(), syslog_header(), vfprintf(), and vsprintf().

Referenced by syslog().

Here is the call graph for this function:

void syslog ( int  pri,
CONST char *  fmt,
  ... 
)

Print log message.

The message is tagged with priority.

Parameters:
priPriority level of this message, selected from the following ordered list (high to low):
  • LOG_EMERG A panic condition.
  • LOG_ALERT A condition that should be corrected immediately.
  • LOG_CRIT Critical conditions, e.g., hard device errors.
  • LOG_ERR Errors.
  • LOG_WARNING Warning messages.
  • LOG_NOTICE Conditions that are not error conditions, but should possibly be handled specially.
  • LOG_INFO Informational messages.
  • LOG_DEBUG Messages that contain information normally of use only when debugging a program.
fmtFormat string containing conversion specifications like printf.

Definition at line 336 of file syslog.c.

References vsyslog().

Referenced by main().

Here is the call graph for this function:

int setlogmask ( int  logmask)

Set the log priority mask level.

Calls to syslog() with a priority not set are ignored. The default allows all priorities to be logged.

Parameters:
logmaskNew priority mask.
Returns:
Previous mask.

Definition at line 355 of file syslog.c.

uint32_t setlogserver ( uint32_t  ip,
uint16_t  port 
)

Set the log server's IP address.

Parameters:
ipIP address in network byte order. If 0, no messages will be sent out.
portPort number. If 0, then standard port is used.
Returns:
Previous IP or (uint32_t)-1 (all bits set) if UDP is not supported.

Definition at line 373 of file syslog.c.

Referenced by main().

void openlog ( CONST char *  ident,
int  logstat,
int  logfac 
)

Open logging for specialized processing.

This function provides for more specialized processing of the messages sent by syslog() and vsyslog().

Parameters:
identThis string that will be prepended to every message.
logstatA bit field specifying logging options, which is formed by OR'ing one or more of the following values:
  • LOG_CONS Ignored but accepted for compatibility.
  • LOG_NDELAY Ignored but accepted for compatibility.
  • LOG_PERROR Additionally write the message to standard error output.
  • LOG_PID Ignored but accepted for compatibility.
logfacEncodes a default facility to be assigned to all messages that do not have an explicit facility encoded:
  • LOG_AUTH The authorization system:
  • LOG_AUTHPRIV The same as LOG_AUTH.
  • LOG_CRON The cron daemon,
  • LOG_DAEMON System daemons, that are not provided for explicitly by other facilities.
  • LOG_FTP The file transfer protocol daemon,
  • LOG_KERN Messages generated by the kernel. These should not be generated by applications.
  • LOG_LPR The line printer spooling system.
  • LOG_MAIL The mail system.
  • LOG_NEWS The network news system.
  • LOG_SYSLOG Messages generated internally by syslog.
  • LOG_USER This is the default facility identifier if none is specified.
  • LOG_UUCP The UUCP system.
  • LOG_LOCAL0..LOG_LOCAL7 Reserved for local use.

Definition at line 419 of file syslog.c.

References closelog(), LOG_NDELAY, malloc(), NutUdpCreateSocket(), strcpy(), strlen(), and syslog_buf.

Referenced by main(), and syslog_header().

Here is the call graph for this function:

void closelog ( void  )

Release system resources occupied by syslog().

Definition at line 450 of file syslog.c.

References free(), NutUdpDestroySocket(), and syslog_buf.

Referenced by openlog().

Here is the call graph for this function:

void vsyslog_P ( int  pri,
PGM_P  fmt_P,
va_list  ap 
)

Print log message.

Alternate form of syslog(), in which the arguments have already been captured using the variable-length argument facilities.

This variant is useful for Harvard architectures only. It allows to place the format string in program space. For other CPUs it is mapped to vsyslog().

Parameters:
priPriority level of this message. See syslog().
fmt_PFormat string containing conversion specifications like printf.
apList of arguments.

Definition at line 99 of file syslog_P.c.

References fputc(), fputs(), stderr, strlen_P, syslog_buf, syslog_flush(), syslog_header(), vfprintf_P(), and vsprintf_P().

Referenced by syslog_P().

Here is the call graph for this function:

void syslog_P ( int  pri,
PGM_P  fmt_P,
  ... 
)

Print log message.

The message is tagged with priority.

This variant is useful for Harvard architectures only. It allows to place the format string in program space. For other CPUs it is mapped to syslog().

Parameters:
priPriority level of this message, selected from the following ordered list (high to low):
  • LOG_EMERG A panic condition.
  • LOG_ALERT A condition that should be corrected immediately.
  • LOG_CRIT Critical conditions, e.g., hard device errors.
  • LOG_ERR Errors.
  • LOG_WARNING Warning messages.
  • LOG_NOTICE Conditions that are not error conditions, but should possibly be handled specially.
  • LOG_INFO Informational messages.
  • LOG_DEBUG Messages that contain information normally of use only when debugging a program.
fmt_PFormat string containing conversion specifications like printf.

Definition at line 143 of file syslog_P.c.

References vsyslog_P().

Here is the call graph for this function:


Variable Documentation

char* syslog_buf

Definition at line 127 of file syslog.c.

Referenced by closelog(), openlog(), syslog_flush(), syslog_header(), vsyslog(), and vsyslog_P().