Add mono log message to error for fatal errors
This commit is contained in:
parent
de465c41dc
commit
c15fb42d45
|
@ -64,10 +64,7 @@ static int get_log_level_id(const char *p_log_level) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDMonoLog::mono_log_callback(const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *) {
|
static String make_text(const char *log_domain, const char *log_level, const char *message) {
|
||||||
FileAccess *f = GDMonoLog::get_singleton()->log_file;
|
|
||||||
|
|
||||||
if (GDMonoLog::get_singleton()->log_level_id >= get_log_level_id(log_level)) {
|
|
||||||
String text(message);
|
String text(message);
|
||||||
text += " (in domain ";
|
text += " (in domain ";
|
||||||
text += log_domain;
|
text += log_domain;
|
||||||
|
@ -75,14 +72,24 @@ void GDMonoLog::mono_log_callback(const char *log_domain, const char *log_level,
|
||||||
text += ", ";
|
text += ", ";
|
||||||
text += log_level;
|
text += log_level;
|
||||||
}
|
}
|
||||||
text += ")\n";
|
text += ")";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GDMonoLog::mono_log_callback(const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *) {
|
||||||
|
FileAccess *f = GDMonoLog::get_singleton()->log_file;
|
||||||
|
|
||||||
|
if (GDMonoLog::get_singleton()->log_level_id >= get_log_level_id(log_level)) {
|
||||||
|
String text = make_text(log_domain, log_level, message);
|
||||||
|
text += "\n";
|
||||||
|
|
||||||
f->seek_end();
|
f->seek_end();
|
||||||
f->store_string(text);
|
f->store_string(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fatal) {
|
if (fatal) {
|
||||||
ERR_PRINT("Mono: FATAL ERROR, ABORTING! Logfile: '" + GDMonoLog::get_singleton()->log_file_path + "'.");
|
String text = make_text(log_domain, log_level, message);
|
||||||
|
ERR_PRINT("Mono: FATAL ERROR '" + text + "', ABORTING! Logfile: '" + GDMonoLog::get_singleton()->log_file_path + "'.");
|
||||||
// Make sure to flush before aborting
|
// Make sure to flush before aborting
|
||||||
f->flush();
|
f->flush();
|
||||||
f->close();
|
f->close();
|
||||||
|
|
Loading…
Reference in New Issue