2 `iris` is asynchronous logging library designed to log messages with minimum overhead to the performance. The cost of logging a message is merely copying the arguments into a lockfree queue.
5 Under the hood, `iris` uses a background thread (logging thread) to offload logging from other threads.
6 1. For every other threads, they keep a lockfree queue to buffer the messages.
7 2. The logging thread periodically scans through all these queues to collect messages, formats them and writes them into log file.
9 A few highlights of the design of `iris` to achieve low latency:
10 1. Buffering messages with thread local lockfree queue.
11 2. Memory is managed by a thread local ringbuffer taking the advantage that logging is FIFO. Because the fact that logging is FIFO. This scales well in multithreaded environment.
12 3. Minimum context switches.
15 The supported severity levels are:
26 By default, `iris` logs messages to `stdout` and filters out severity level less than `INFO`.
29 #include <iris/level_logger.h>
31 // this creates a logging thread, logs messages to stdout
32 iris::level_logger g_log;
34 int main (int argc, char const *argv[]) {
35 //configure thread level parameters, these should be done before any logging
37 g_log.set_thread_queue_size(1024);
39 g_log.set_thread_ringbuf_size(10240);
41 g_log.info("Greetings from %s, bye %d\n", 'iris', 0);
43 //this tells logging thread to persist the data into file and waits
44 g_log.sync_and_close();
49 Using a `file_writer` to logs all messages into a file:
51 #include <iris/level_logger.h>
52 #include <iris/file_writer.h>
54 iris::file_writer writer("./log.txt");
55 // this creates a logging thread
56 iris::level_logger g_log(&writer, iris::TRACE);
58 int main (int argc, char const *argv[]) {
59 //configure thread level parameters, these should be done before any logging
61 g_log.set_thread_queue_size(1024);
63 g_log.set_thread_ringbuf_size(20480);
65 g_log.info("Greetings from %s, bye %d\n", 'iris', 0);
67 //this tells logging thread to persist the data into file and waits
68 g_log.sync_and_close();
74 # Building & Installation
76 To build the library, simply clone the projet, go inside the `iris` direcotry and run following commands.
82 To integrate `iris` into your program, link with `-liris` options.