Example #1
0
static void mono_log_callback(const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data) {

	FileAccess *f = GDMonoLog::get_singleton()->get_log_file();

	if (GDMonoLog::get_singleton()->get_log_level_id() >= log_level_get_id(log_level)) {
		String text(message);
		text += " (in domain ";
		text += log_domain;
		if (log_level) {
			text += ", ";
			text += log_level;
		}
		text += ")\n";

		f->seek_end();
		f->store_string(text);
	}

	if (fatal) {
		ERR_PRINTS("Mono: FATAL ERROR, ABORTING! Logfile: " + GDMonoLog::get_singleton()->get_log_file_path() + "\n");
		// If we were to abort without flushing, the log wouldn't get written.
		f->flush();
		abort();
	}
}