From 87f165ac89990a89198f256e1794e14d2d07dae3 Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Thu, 3 Oct 2019 10:22:20 +0300 Subject: diagnostic: allow setting output stream(s). Added a function to allow changing a channel's output stream. This also makes it possible to direct output to a file. Signed-off-by: Gediminas Jakutis --- src/diagnostic/diagnostic.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/diagnostic/diagnostic.c') diff --git a/src/diagnostic/diagnostic.c b/src/diagnostic/diagnostic.c index 9bb4396..58a0292 100644 --- a/src/diagnostic/diagnostic.c +++ b/src/diagnostic/diagnostic.c @@ -45,6 +45,32 @@ int rin_diag_flags(int flag, int action) return 0; } +int rin_diag_set_outstream(enum rin_diag_outstream channel, FILE *stream) +{ + if (!stream) { + return EINVAL; + } + + switch (channel) { + case rin_diag_err: + state.err = stream; + break; + case rin_diag_warn: + state.warn = stream; + break; + case rin_diag_fixme: + state.fixme = stream; + break; + case rin_diag_info: + state.info = stream; + break; + default: + return EINVAL; + } + + return 0; +} + void rin_err(const char *format, ...) { va_list args; -- cgit v1.2.3