diff --git a/platform-independent/c/core/src/mpw-util.c b/platform-independent/c/core/src/mpw-util.c index e879712e..fa1ebacb 100644 --- a/platform-independent/c/core/src/mpw-util.c +++ b/platform-independent/c/core/src/mpw-util.c @@ -103,6 +103,8 @@ void mpw_log_ssink(LogLevel level, const char *file, int line, const char *funct if (sink) sink( &record ); } + if (!sinks_count) + mpw_log_sink_file( &record ); if (record.level <= LogLevelFatal) abort(); diff --git a/platform-independent/c/core/src/mpw-util.h b/platform-independent/c/core/src/mpw-util.h index c43b4634..fd93a0a8 100644 --- a/platform-independent/c/core/src/mpw-util.h +++ b/platform-independent/c/core/src/mpw-util.h @@ -53,12 +53,14 @@ typedef struct { const char *message; } MPLogEvent; -/** A log sink describes a function that can receive log events when registered. */ +/** A log sink describes a function that can receive log events. */ typedef void (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); bool mpw_log_sink_unregister(MPLogSink *sink); -/** mpw_log_sink_file is a sink that writes log messages to the mpw_log_cli_file, which defaults to stderr. */ +/** mpw_log_sink_file is a sink that writes log messages to the mpw_log_sink_file, which defaults to stderr. */ extern MPLogSink mpw_log_sink_file; extern FILE *mpw_log_sink_file_target;