mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-25 21:59:11 +01:00
82153bfd5a
This adds a buffer struct and some utility functions for continously logging into a small buffer. In the end the buffer is flushed as a single line to the specified log channel.
28 lines
741 B
C
28 lines
741 B
C
#ifndef LOG_H
|
|
#define LOG_H
|
|
|
|
#include <libliftoff.h>
|
|
|
|
#ifdef __GNUC__
|
|
#define _LIFTOFF_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end)))
|
|
#else
|
|
#define _LIFTOFF_ATTRIB_PRINTF(start, end)
|
|
#endif
|
|
|
|
bool log_has(enum liftoff_log_importance verbosity);
|
|
|
|
void liftoff_log(enum liftoff_log_importance verbosity,
|
|
const char *format, ...) _LIFTOFF_ATTRIB_PRINTF(2, 3);
|
|
void liftoff_log_errno(enum liftoff_log_importance verbosity, const char *msg);
|
|
|
|
struct liftoff_log_buffer {
|
|
char *data;
|
|
size_t len, cap;
|
|
};
|
|
|
|
void liftoff_log_buffer_append(struct liftoff_log_buffer *buf,
|
|
const char *fmt, ...);
|
|
void liftoff_log_buffer_flush(struct liftoff_log_buffer *buf,
|
|
enum liftoff_log_importance verbosity);
|
|
|
|
#endif
|