el_flush¶
NAME¶
el_flush, el_oflush - flush logs from all buffers to underlying devices.
SYNOPSIS¶
include <embedlog.h>
int el_flush(void)
int el_oflush(struct el *el)
DESCRIPTION¶
embedlog (and underlying drivers, operating systems, libraries etc) to improve performance, may buffer message before commiting changes to actual device. And it's ok, there is really no need to waste resources every time you want to log 50 bytes of debug print on commiting message physically to the drive - or send via network. It's much more common to buffer messages in RAM until certain amount of bytes are ready to send - and then send a bunch of data in one quick burst. But that behaviour is not always desired, like in situation in which we know we won't be printing logs for long time. For such situation explicit flush may in order.
el_flush(3) flushes logs from all buffers to underlying device. For example, when logs are printed to file, logs are written through buffered stdio functions, which may result in some logs never being actually put into block device in case of abnormal application crash. This function will do everything what is in its power to make sure logs landed on underlying device. This applies to files, but also to logs with network output.
el_oflush(3) works just the same, but accepts custom el object as argument.
RETURN VALUE¶
Functions return 0 upon successful flush or -1 on errors. When -1 was returned there is no guarantee that data has landed on underlying device.
ERRORS¶
el_flush(3) and el_oflush(3) may return errors from functions like: fflush, fileno, fsync, fseek, ftell, fopen and/or fclose.
el_oflush(3) may additionally return:
- EINVAL
Passed el object is not valid