| 345 | #endif |
| 346 | |
| 347 | void OnLogCallback(const char* logDomain, const char* logLevel, const char* message, mono_bool fatal, void* userData) |
| 348 | { |
| 349 | String currentDomain(logDomain); |
| 350 | String msg(message); |
| 351 | msg.Replace('\n', ' '); |
| 352 | |
| 353 | static const char* monoErrorLevels[] = |
| 354 | { |
| 355 | nullptr, |
| 356 | "error", |
| 357 | "critical", |
| 358 | "warning", |
| 359 | "message", |
| 360 | "info", |
| 361 | "debug" |
| 362 | }; |
| 363 | |
| 364 | uint32 errorLevel = 0; |
| 365 | if (logLevel != nullptr) |
| 366 | { |
| 367 | for (uint32 i = 1; i < 7; i++) |
| 368 | { |
| 369 | if (strcmp(monoErrorLevels[i], logLevel) == 0) |
| 370 | { |
| 371 | errorLevel = i; |
| 372 | break; |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | if (currentDomain.IsEmpty()) |
| 378 | { |
| 379 | auto domain = MCore::GetActiveDomain(); |
| 380 | if (domain != nullptr) |
| 381 | { |
| 382 | currentDomain = domain->GetName().Get(); |
| 383 | } |
| 384 | else |
| 385 | { |
| 386 | currentDomain = "null"; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | #if 0 |
| 391 | // Print C# stack trace (crash may be caused by the managed code) |
| 392 | if (mono_domain_get() && Assemblies::FlaxEngine.Assembly->IsLoaded()) |
| 393 | { |
| 394 | const auto managedStackTrace = DebugLog::GetStackTrace(); |
| 395 | if (managedStackTrace.HasChars()) |
| 396 | { |
| 397 | LOG(Warning, "Managed stack trace:"); |
| 398 | LOG_STR(Warning, managedStackTrace); |
| 399 | } |
| 400 | } |
| 401 | #endif |
| 402 | |
| 403 | if (errorLevel == 0) |
| 404 | { |