DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
The NuttX SYSLOG is an architecture for getting debug and status information from the system. The syslogging interfaces are defined in the header file include/syslog.h. The primary interface to SYSLOG sub-system is the function syslog() and, to a lesser extent, its companion vsyslog():
| Code Block |
|---|
/**************************************************************************** * Name: syslog and |
...
vsyslog * * Description: * syslog() generates a log message. The priority argument is formed |
...
by * ORing the facility and the level values (see include/syslog.h). |
...
The * remaining arguments are a format, as in printf and any arguments to the * format. * * The NuttX implementation does not support any special formatting * characters beyond those supported by printf. * * The function vsyslog() performs the same task as syslog() with the * difference that it takes a set of arguments which have been obtained * using the stdarg variable argument list macros. * ****************************************************************************/ |
...
| Code Block |
|---|
int syslog(int priority, FAR const IPTR char *format, ...); int vsyslog(int priority, FAR const IPTR char *src, va_list ap); |
The additional setlogmask() interface can use use to filter SYSLOG output:
| Code Block |
|---|
/**************************************************************************** * Name: |
...
setlogmask * * Description: * The setlogmask() function sets the logmask and returns the |
...
previous * mask. If the mask argument is 0, the current logmask is not modified. |
...
* * The SYSLOG priorities are: LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, |
...
* LOG_WARNING, LOG_NOTICE, LOG_INFO, and LOG_DEBUG. The bit |
...
corresponding * to a priority p is LOG_MASK(p); LOG_UPTO(p) provides the mask of |
...
all * priorities in the above list up to and including p. * * Per OpenGroup.org "If the maskpri argument is 0, the current log mask * is not modified." In this implementation, the value zero is permitted * in order to disable all syslog levels. * * REVISIT: Per POSIX the syslog mask should be a per-process value but in * NuttX, the scope of the mask is dependent on the nature of the build: * * Flat Build: There is one, global SYSLOG mask that controls all output. * Protected Build: There are two SYSLOG masks. One within the kernel * that controls only kernel output. And one in user-space that controls * only user SYSLOG output. * Kernel Build: The kernel build is compliant with the POSIX requirement: * There will be one mask for for each user process, controlling the * SYSLOG output only form that process. There will be a separate mask * accessable only in the kernel code to control kernel SYSLOG output. * ****************************************************************************/ |
...
| Code Block |
|---|
int int setlogmask(int mask); |
These are all standard interfaces as defined at OpenGroup.org.
...
The channel interface is instantiated by calling syslog_channel():
| Code Block |
|---|
/**************************************************************************** * Name: syslog_channel |
...
* * Description: |
...
* Configure the SYSLOGging function to use the provided channel to |
...
* generate SYSLOG output. |
...
* * Input Parameters: |
...
* channel - Provides the interface to the channel to be used. |
...
* * Returned Value: |
...
* Zero (OK)is returned on success. A negated errno value is returned |
...
* on any failure. |
...
* ****************************************************************************/ |
...
| Code Block |
|---|
int syslog_channel(FAR const struct syslog_channel_s *channel); |
...
The syslog channel device is initialized when the bring-up logic calls syslog_intialize():
| Code Block |
|---|
/**************************************************************************** * Name: syslog_initialize |
...
* * Description: * One power up, the SYSLOG facility is non-existent or limited to very * low-level output. This function is called later in the initialization * sequence after full driver support has been initialized. It installs * the configured SYSLOG drivers and enables full SYSLOGing capability. * * This function performs these basic operations: * * - Initialize the SYSLOG device * - Call syslog_channel() to begin using that device. * * If CONFIG_ARCH_SYSLOG is selected, then the architecture-specific * logic will provide its own SYSLOG device initialize which must include * as a minimum a call to syslog_channel() to use the device. * * Input Parameters: * phase - One of {SYSLOG_INIT_EARLY, SYSLOG_INIT_LATE} |
...
* * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned |
...
on * any failure. * ****************************************************************************/ |
...
| Code Block |
|---|
#ifndef CONFIG_ARCH_SYSLOG int syslog_initialize(enum syslog_init_e phase); #else # define syslog_initialize(phase) #endif |
Different types of SYSLOG devices have different OS initialization requirements. Some are available immediately at reset, some are available after some basic OS initialization, and some only after OS is fully initialized. In order to satisfy these different initialization requirements, syslog_initialize() is called twice from the boot-up logic:
...
The interface syslog_file_channel() is used to configure the SYSLOG file channel:
| Code Block |
|---|
/**************************************************************************** * Name: syslog_file_channel |
...
* * Description: * Configure to use a file in a mounted file system at 'devpath' as the * SYSLOG channel. * * This tiny function is simply a wrapper around syslog_dev_initialize() |
...
* and syslog_channel(). It calls syslog_dev_initialize() to |
...
configure * the character file at 'devpath then calls syslog_channel() to use |
...
that * device as the SYSLOG output channel. * * File SYSLOG channels differ from other SYSLOG channels in that they * cannot be established until after fully booting and mounting the target * file system. This function would need to be called from board-specific * bring-up logic AFTER mounting the file system containing 'devpath'. * * SYSLOG data generated prior to calling syslog_file_channel will, of * course, not be included in the file. * * NOTE interrupt level SYSLOG output will be lost in this case unless * the interrupt buffer is used. * * Input Parameters: * devpath - The full path to the file to be used for SYSLOG output. * This may be an existing file or not. If the file exists, * syslog_file_channel() will append new SYSLOG data to the end of |
...
the * file. If it does not, then syslog_file_channel() will create |
...
the * file. * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on * any failure. * ****************************************************************************/ |
...
| Code Block |
|---|
#ifdef CONFIG_SYSLOG_FILE int syslog_file_channel(FAR const char *devpath); #endif |
References: drivers/syslog/syslog_filechannel.c, drivers/syslog/syslog_device.c, and include/nuttx/syslog/syslog.h.
...
If the option CONFIG_SYSLOG_CHARDEV is selected then support for a special character device at /dev/syslog is supported. The function {{ syslog_register()}} can be used to register that character device:
| Code Block |
|---|
/**************************************************************************** * Name: syslog_register |
...
* * Description: * Register a simple character driver at /dev/syslog whose write() |
...
method * will transfer data to the SYSLOG device. This can be useful if, for * example, you want to redirect the output of a program to the SYSLOG. * * NOTE that unlike other syslog output, this data is unformatted raw * byte output with no time-stamping or any other SYSLOG features * supported. * ****************************************************************************/ |
...
| Code Block |
|---|
void syslog_register(void); |
...