diff --git a/include/villas/log.h b/include/villas/log.h index e5699203e..5234f71bd 100644 --- a/include/villas/log.h +++ b/include/villas/log.h @@ -98,6 +98,7 @@ struct log { int level; long facilities; /**< Debug facilities used by the debug() macro. */ const char *path; /**< Path of the log file. */ + char *prefix; /**< Prefix each line with this string. */ FILE *file; /**< Send all log output to this file / stdout / stderr. */ }; diff --git a/lib/Makefile.villas.inc b/lib/Makefile.villas.inc index 49090e7fb..9bc9afffb 100644 --- a/lib/Makefile.villas.inc +++ b/lib/Makefile.villas.inc @@ -33,7 +33,7 @@ LIB_SRCS += $(addprefix lib/kernel/, kernel.c rt.c) \ utils.c super_node.c hist.c timing.c pool.c list.c queue.c \ queue_signalled.c memory.c advio.c plugin.c node_type.c stats.c \ mapping.c io.c shmem.c config_helper.c crypt.c compat.c \ - log_table.c log_helper.c io_format.c periodic_task.c \ + log_table.c log_helper.c io_format.c task.c \ ) LIB_LDFLAGS = -shared diff --git a/lib/io.c b/lib/io.c index 0bd7d85ea..6abf70bff 100644 --- a/lib/io.c +++ b/lib/io.c @@ -75,9 +75,9 @@ int io_stream_open(struct io *io, const char *uri) if (io->advio.output == NULL) return -1; - io->advio.input = afopen(uri, "r"); + io->advio.input = afopen(uri, "a+"); if (io->advio.input == NULL) - return -1; + return -2; } } else { diff --git a/lib/io_format.c b/lib/io_format.c index 5c9dc170c..bbf3d1bd8 100644 --- a/lib/io_format.c +++ b/lib/io_format.c @@ -27,11 +27,16 @@ int io_format_sscan(struct io_format *fmt, char *buf, size_t len, size_t *rbytes, struct sample *smps[], unsigned cnt, int *flags) { + if (!flags) + flags = &fmt->flags; + return fmt->sscan ? fmt->sscan(buf, len, rbytes, smps, cnt, flags) : -1; } int io_format_sprint(struct io_format *fmt, char *buf, size_t len, size_t *wbytes, struct sample *smps[], unsigned cnt, int flags) { + flags |= fmt->flags; + return fmt->sprint ? fmt->sprint(buf, len, wbytes, smps, cnt, flags) : -1; }