Skip to content

Commit d0e450a

Browse files
committed
sokol_log: silence non-error output by default, don't print extra newlines
users don't know what these messages mean, it's useless output. the extra newlines break the formatting style of other logging. instead, disable output for higher log levels by default, based on our own runtime debug settings. we might always compile in the messages for convenience as well, not sure why sokol chooses not to.
1 parent 10dfe68 commit d0e450a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/sokol_log.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,14 @@ EM_JS(void, slog_js_log, (uint32_t level, const char* c_str), {
248248
})
249249
#endif
250250

251+
extern int debug;
252+
251253
SOKOL_API_IMPL void slog_func(const char* tag, uint32_t log_level, uint32_t log_item, const char* message, uint32_t line_nr, const char* filename, void* user_data) {
252254
_SOKOL_UNUSED(user_data);
253255

256+
if (debug == 0 && log_level > 1)
257+
return;
258+
254259
const char* log_level_str;
255260
switch (log_level) {
256261
case 0: log_level_str = "panic"; break;
@@ -301,7 +306,7 @@ SOKOL_API_IMPL void slog_func(const char* tag, uint32_t log_level, uint32_t log_
301306
str = _slog_append("\n\t", str, end);
302307
str = _slog_append(message, str, end);
303308
}
304-
str = _slog_append("\n\n", str, end);
309+
str = _slog_append("\n", str, end);
305310
if (0 == log_level) {
306311
str = _slog_append("ABORTING because of [panic]\n", str, end);
307312
(void)str;

0 commit comments

Comments
 (0)