Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Logging to a RAM Buffer

Default Debug Output

By default, when you enable debug output, that output goes to the system console and is mixed up with the normal console output. Normally, that is sufficient. However there are some cases where you might want to do things differently. For example, if there is time critical debug output that interferes with the operation of the device. Or, if you would like to separate the normal console output from the debug output.

...

With some creative configuration of the NuttX SYStem LOGging (SYSLOG) feature, these problems can all be eliminated.

The syslog Device

Debug output goes to the syslog device. As mentioned above, the default syslog device device is the system console. However there are many options to control the behavior of the syslog – too many in fact. There are so many options that you will probably have to perform experiments to get the syslog working as you would like it too.

The RAMLOG Device

The RAMLOG device is a special character device that can really be used for most any purpose. However, the RAMLOG device has some special attributes that make it ideal for use as a syslogging device.

  • It supports the syslog_putc interface needed for system logging
  • It behaves much like a pipe: It implements a queue. Writing to the RAMLOG device adds data to the head of the queue; reading from the RAMLOG device removes data from the tail of the queue.
  • It can be configured to return EOF when you try to read and there is nothing available in the RAMLOG.

Using the RAMLOG as the syslog Device

This Wiki page addresses the setup for one configuration: Using a RAMLOG as the syslog device. A RAMLOG is a circular buffer in memory. In this configuration, all debugout output goes to this circular buffer and can later be retrieved using the NSH dmesg command

...