2
0

Default to mpw_log_sink_file if no sinks are registered.

This commit is contained in:
Maarten Billemont 2020-02-12 22:32:14 -05:00
parent f32f2a6726
commit 485cf65694
2 changed files with 6 additions and 2 deletions

View File

@ -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();

View File

@ -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;