Crate ulog [] [src]

ulog: Flexible asynchronous logging

Features:

  • Asynchronous: ulog sends all log messages through a channel to another thread as soon as possible, trying to minimize the time the logging thread spends processing the log.
  • Standard log: ulog uses the de-facto standard logging facade of log, allowing access to familiar features.
  • Flexible: ulog is small but flexible, allowing different use cases other than standard file or stream logging. Log handling is done by passing a closure that is executed in a different thread.

Intended use and example

ulog is intended for use on embedded Linux applications that are multithreaded and require a single thread to provide hard real-time guarantees. Logs made using ulog are sent through a synchronous channel before being processed, if logging cannot be completed in constant time, the message is dropped and an error flag is set.

Example use case

Consider an application controlling a piece of hardware that has moderate real-time guarantees (in the 10s of milliseconds). Allocations and other execution will usually run just fine, however writing logs to disk or stderr can occasionally slow down the process by hundres of millliseconds under some conditions.

To avoid this, ulog can be used to offloaded heavy I/O into a separate thread, if enough execution threads are available and scheduling is setup correctly, this will guarantee that logging never takes longer than a string format and a few small allocations.

Structs

AsyncLogger

Asynchronous logger

LogMessage

A log entry

Functions

init

Initialize ulog logging.

init_stderr

Initialize ulog loggin with default stderr-based logging.