Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: create log folder before logging #1200

Merged
merged 9 commits into from
Sep 13, 2024
4 changes: 4 additions & 0 deletions engine/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void RunServer() {
<< " Port: " << config.apiServerPort << "\n";

// Create logs/ folder and setup log to file
std::filesystem::create_directory(config.logFolderPath);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using std::filesystem::create_directories should be better. Seems like it handle create directory recursively.
https://en.cppreference.com/w/cpp/filesystem/create_directory

Also, I'm worry about concatenate path using / might not work on windows. Should using std::filesystem::path

std::filesystem::create_directory(config.logFolderPath + "/" +
cortex_utils::logs_folder);
trantor::FileLogger asyncFileLogger;
Expand Down Expand Up @@ -160,6 +161,9 @@ int main(int argc, char* argv[]) {
return 0;
} else {
auto config = file_manager_utils::GetCortexConfig();
std::filesystem::create_directory(config.logFolderPath);
std::filesystem::create_directory(config.logFolderPath + "/" +
cortex_utils::logs_folder);
trantor::FileLogger asyncFileLogger;
asyncFileLogger.setFileName(config.logFolderPath + "/" +
cortex_utils::logs_cli_base_name);
Expand Down
Loading