+
+ if ( g_hLogFile != 0 ) {
+ // prevent parallel write
+ static std::mutex log_file_mutex;
+ std::lock_guard<std::mutex> guard(log_file_mutex);
+
+ fwrite( buf, 1, length, g_hLogFile );
+ if ( contains_newline ) {
+ fflush( g_hLogFile );
+ }
+ }
+
+ if ( level != SYS_NOCON && g_console ) {
+ auto data = reinterpret_cast<Gtk_Idle_Print_Data *>( malloc( sizeof(struct Gtk_Idle_Print_Data) ) );
+ if (data != nullptr) {
+ *data = { level, g_strndup(buf, length), length, contains_newline };
+ gdk_threads_add_idle(Gtk_Idle_Print, (gpointer)data);
+ }
+ }
+