MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / init_logs

Function init_logs

src/main.cpp:422–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420#endif
421
422void init_logs(MainStruct& mS) {
423 char* homePathSDL = SDL_GetCurrentDirectory();
424 mS.homePath = std::filesystem::path(homePathSDL);
425 SDL_free(homePathSDL);
426#ifdef CONFIG_NEXT_TO_EXECUTABLE
427 std::string CONFIG_FOLDER_NAME = "config";
428 std::filesystem::create_directory(CONFIG_FOLDER_NAME);
429 mS.configPath = mS.homePath / CONFIG_FOLDER_NAME;
430#else
431 char* configPathSDL = SDL_GetPrefPath("ErrorAtLine0", "infinipaint");
432 mS.configPath = std::filesystem::path(configPathSDL);
433 SDL_free(configPathSDL);
434#endif
435 mS.logFile = std::ofstream(mS.configPath / "log.txt");
436 Logger::get().set_log_function(Logger::LogType::FATAL, [&, mS = &mS](const std::string& text) {
437 mS->logFile << "[FATAL] " << text << std::endl;
438 std::cerr << "[FATAL] " << text << std::endl;
439 mS->logFile.close();
440 });
441 Logger::get().set_log_function(Logger::LogType::INFO, [&, mS = &mS](const std::string& text) {
442 mS->logFile << "[INFO] " << text << std::endl;
443 Logger::get().cross_platform_println("[INFO] " + text);
444 });
445
446 Logger::get().log(Logger::LogType::INFO, "Home Path: " + mS.homePath.string());
447 Logger::get().log(Logger::LogType::INFO, "Config Path: " + mS.configPath.string());
448}
449
450SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
451 std::vector<std::filesystem::path> listOfFilesToOpenFromCommand;

Callers 1

SDL_AppInitFunction · 0.85

Calls 6

set_log_functionMethod · 0.80
logMethod · 0.80
closeMethod · 0.65
getFunction · 0.50
stringMethod · 0.45

Tested by

no test coverage detected