diff --git a/platform-independent/c/core/src/mpw-util.c b/platform-independent/c/core/src/mpw-util.c index e87996c9..9c024747 100644 --- a/platform-independent/c/core/src/mpw-util.c +++ b/platform-independent/c/core/src/mpw-util.c @@ -97,14 +97,15 @@ void mpw_log_ssink(LogLevel level, const char *file, int line, const char *funct .message = message, }; + bool sunk = false; for (unsigned int s = 0; s < sinks_count; ++s) { MPLogSink *sink = sinks[s]; if (sink) - sink( &record ); + sunk |= sink( &record ); } - if (!sinks_count) - mpw_log_sink_file( &record ); + if (!sunk) + sunk = mpw_log_sink_file( &record ); if (record.level <= LogLevelError) { /* error breakpoint */; @@ -113,7 +114,7 @@ void mpw_log_ssink(LogLevel level, const char *file, int line, const char *funct abort(); } -void mpw_log_sink_file(const MPLogEvent *record) { +bool mpw_log_sink_file(const MPLogEvent *record) { if (!mpw_log_sink_file_target) mpw_log_sink_file_target = stderr; @@ -145,6 +146,7 @@ void mpw_log_sink_file(const MPLogEvent *record) { } fprintf( mpw_log_sink_file_target, "%s\n", record->message ); + return true; } void mpw_uint16(const uint16_t number, uint8_t buf[2]) { diff --git a/platform-independent/c/core/src/mpw-util.h b/platform-independent/c/core/src/mpw-util.h index 145890f6..ec18dde5 100644 --- a/platform-independent/c/core/src/mpw-util.h +++ b/platform-independent/c/core/src/mpw-util.h @@ -54,7 +54,7 @@ typedef struct { } MPLogEvent; /** A log sink describes a function that can receive log events. */ -typedef void (MPLogSink)(const MPLogEvent *event); +typedef bool (MPLogSink)(const MPLogEvent *event); /** To receive events, sinks need to be registered. If no sinks are registered, log events are sent to the mpw_log_sink_file sink. */ bool mpw_log_sink_register(MPLogSink *sink);