MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / OnLogCallback

Function OnLogCallback

Source/Engine/Scripting/Runtime/Mono.cpp:347–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345#endif
346
347void 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 {

Callers

nothing calls this directly

Calls 8

CLRInnerExceptionClass · 0.85
ReplaceMethod · 0.80
FormatFunction · 0.50
IsEmptyMethod · 0.45
GetMethod · 0.45
GetNameMethod · 0.45
IsLoadedMethod · 0.45
HasCharsMethod · 0.45

Tested by

no test coverage detected