MCPcopy Create free account
hub / github.com/defold/defold / LogInitialize

Function LogInitialize

engine/dlib/src/dlib/log.cpp:437–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435}
436
437void LogInitialize(const LogParams* params)
438{
439 g_TotalBytesLogged = 0;
440
441 if (dmAtomicGet32(&g_LogServerInitialized) != 0)
442 {
443 fprintf(stderr, "ERROR:DLIB: dmLog already initialized\n");
444 return;
445 }
446
447 dmSpinlock::Create(&g_LogServerLock);
448
449 dmSocket::Socket server_socket = dmSocket::INVALID_SOCKET_HANDLE;
450 uint16_t port = 0;
451
452 if (dLib::IsDebugMode() && dLib::FeaturesSupported(DM_FEATURE_BIT_SOCKET_SERVER_TCP))
453 {
454 dmLogInitSocket(server_socket);
455 if (server_socket != dmSocket::INVALID_SOCKET_HANDLE)
456 {
457 dmSocket::Address address;
458 dmSocket::GetName(server_socket, &address, &port);
459 }
460 }
461
462 dmMessage::HSocket message_socket = 0;
463 dmMessage::Result mr;
464
465 mr = dmMessage::NewSocket("@log", &message_socket);
466 if (mr != dmMessage::RESULT_OK)
467 {
468 fprintf(stderr, "ERROR:DLIB: Unable to create @log message socket\n");
469 if (message_socket != 0)
470 dmMessage::DeleteSocket(message_socket);
471 if (server_socket != dmSocket::INVALID_SOCKET_HANDLE)
472 dmSocket::Delete(server_socket);
473 return;
474 }
475
476 dmLogServer* server = new dmLogServer(server_socket, port, message_socket);
477 g_dmLogServer = server;
478
479 server->m_Thread = 0;
480 if(dLib::FeaturesSupported(DM_FEATURE_BIT_SOCKET_SERVER_TCP)) // e.g. Emscripten doesn't support it
481 {
482 server->m_Thread = dmThread::New(dmLogThread, 0x80000, 0, "log");
483 }
484
485 dmAtomicStore32(&g_LogServerInitialized, 1);
486
487 dmAtomicStore32(&g_ListenersCount, 0);
488 dmSpinlock::Create(&g_ListenerLock);
489
490 /*
491 * This message is parsed by editor 2 - don't remove or change without
492 * corresponding changes in engine.clj
493 */
494 dmLogInfo("Log server started on port %u", (unsigned int) port);

Callers 15

SetUpMethod · 0.85
mainFunction · 0.85
dmLogInitializeFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
TESTFunction · 0.85
dmEngineInitializeFunction · 0.85
SetUpMethod · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 11

dmAtomicGet32Function · 0.85
IsDebugModeFunction · 0.85
FeaturesSupportedFunction · 0.85
dmLogInitSocketFunction · 0.85
NewSocketFunction · 0.85
DeleteSocketFunction · 0.85
dmAtomicStore32Function · 0.85
CreateFunction · 0.70
GetNameFunction · 0.70
DeleteFunction · 0.70
NewFunction · 0.70

Tested by 15

SetUpMethod · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
TESTFunction · 0.68
SetUpMethod · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68