diff --git a/engine/controllers/server.cc b/engine/controllers/server.cc index 2e8a93b8c..f19b1412e 100644 --- a/engine/controllers/server.cc +++ b/engine/controllers/server.cc @@ -347,8 +347,8 @@ void server::LoadModel(const HttpRequestPtr& req, if (engine_type == kLlamaEngine) { //fix for llamacpp engine first auto config = file_manager_utils::GetCortexConfig(); if (en->IsSupported("SetFileLogger")) { - en->SetFileLogger(config.maxLogLines, config.logFolderPath + "/" + - cortex_utils::logs_base_name); + en->SetFileLogger(config.maxLogLines, (std::filesystem::path(config.logFolderPath) / + std::filesystem::path(config.logLlamaCppPath)).string()); } else { LOG_WARN << "Method SetFileLogger is not supported yet"; } diff --git a/engine/test/components/test_cortex_config.cc b/engine/test/components/test_cortex_config.cc index 513716940..865ebeb59 100644 --- a/engine/test/components/test_cortex_config.cc +++ b/engine/test/components/test_cortex_config.cc @@ -9,10 +9,16 @@ class CortexConfigTest : public ::testing::Test { void SetUp() override { // Set up default configuration - default_config = { - "default_log_path", "default_data_path", 1000, - kDefaultHost, kDefaultPort, kDefaultCheckedForUpdateAt, - kDefaultLatestRelease}; + default_config = {"default_log_path", + "default_llamacpp_log_path", + "default_tensorrtllm_log_path", + "default_onnx_log_path", + "default_data_path", + 1000, + kDefaultHost, + kDefaultPort, + kDefaultCheckedForUpdateAt, + kDefaultLatestRelease}; } void TearDown() override { @@ -24,8 +30,16 @@ class CortexConfigTest : public ::testing::Test { }; TEST_F(CortexConfigTest, DumpYamlConfig_WritesCorrectly) { - CortexConfig config = {"log_path", "data_path", 5000, "localhost", - "8080", 123456789, "v1.0.0"}; + CortexConfig config = {"log_path", + "default_llamacpp_log_path", + "default_tensorrtllm_log_path", + "default_onnx_log_path", + "data_path", + 5000, + "localhost", + "8080", + 123456789, + "v1.0.0"}; DumpYamlConfig(config, test_file_path); @@ -43,8 +57,16 @@ TEST_F(CortexConfigTest, DumpYamlConfig_WritesCorrectly) { TEST_F(CortexConfigTest, FromYaml_ReadsCorrectly) { // First, create a valid YAML configuration file - CortexConfig config = {"log_path", "data_path", 5000, "localhost", - "8080", 123456789, "v1.0.0"}; + CortexConfig config = {"log_path", + "default_llamacpp_log_path", + "default_tensorrtllm_log_path", + "default_onnx_log_path", + "data_path", + 5000, + "localhost", + "8080", + 123456789, + "v1.0.0"}; DumpYamlConfig(config, test_file_path); diff --git a/engine/utils/config_yaml_utils.h b/engine/utils/config_yaml_utils.h index 22672b5ac..8ceabe2eb 100644 --- a/engine/utils/config_yaml_utils.h +++ b/engine/utils/config_yaml_utils.h @@ -9,6 +9,9 @@ namespace config_yaml_utils { struct CortexConfig { std::string logFolderPath; + std::string logLlamaCppPath; + std::string logTensorrtLLMPath; + std::string logOnnxPath; std::string dataFolderPath; int maxLogLines; std::string apiServerHost; @@ -35,6 +38,9 @@ inline void DumpYamlConfig(const CortexConfig& config, } YAML::Node node; node["logFolderPath"] = config.logFolderPath; + node["logLlamaCppPath"] = config.logLlamaCppPath; + node["logTensorrtLLMPath"] = config.logTensorrtLLMPath; + node["logOnnxPath"] = config.logOnnxPath; node["dataFolderPath"] = config.dataFolderPath; node["maxLogLines"] = config.maxLogLines; node["apiServerHost"] = config.apiServerHost; @@ -63,12 +69,22 @@ inline CortexConfig FromYaml(const std::string& path, (!node["logFolderPath"] || !node["dataFolderPath"] || !node["maxLogLines"] || !node["apiServerHost"] || !node["apiServerPort"] || !node["checkedForUpdateAt"] || - !node["latestRelease"]); + !node["latestRelease"] || !node["logLlamaCppPath"] || + !node["logOnnxPath"] || !node["logTensorrtLLMPath"]); CortexConfig config = { .logFolderPath = node["logFolderPath"] ? node["logFolderPath"].as() : default_cfg.logFolderPath, + .logLlamaCppPath = node["logLlamaCppPath"] + ? node["logLlamaCppPath"].as() + : default_cfg.logLlamaCppPath, + .logTensorrtLLMPath = node["logTensorrtLLMPath"] + ? node["logTensorrtLLMPath"].as() + : default_cfg.logTensorrtLLMPath, + .logOnnxPath = node["logOnnxPath"] + ? node["logOnnxPath"].as() + : default_cfg.logOnnxPath, .dataFolderPath = node["dataFolderPath"] ? node["dataFolderPath"].as() : default_cfg.dataFolderPath, diff --git a/engine/utils/file_manager_utils.h b/engine/utils/file_manager_utils.h index 3dccb042a..6e8dacced 100644 --- a/engine/utils/file_manager_utils.h +++ b/engine/utils/file_manager_utils.h @@ -6,6 +6,7 @@ #include "services/download_service.h" #include "utils/config_yaml_utils.h" + #if defined(__APPLE__) && defined(__MACH__) #include #elif defined(__linux__) @@ -20,6 +21,9 @@ constexpr std::string_view kDefaultConfigurationPath = "user_home"; constexpr std::string_view kProdVariant = "prod"; constexpr std::string_view kBetaVariant = "beta"; constexpr std::string_view kNightlyVariant = "nightly"; +constexpr char kLogsLlamacppBaseName[] = "./logs/cortex.log"; +constexpr char kLogsTensorrtllmBaseName[] = "./logs/cortex.log"; +constexpr char kLogsOnnxBaseName[] = "./logs/cortex.log"; inline std::filesystem::path GetExecutableFolderContainerPath() { #if defined(__APPLE__) && defined(__MACH__) @@ -156,6 +160,9 @@ inline config_yaml_utils::CortexConfig GetCortexConfig() { file_manager_utils::GetHomeDirectoryPath() / default_data_folder_name; auto default_cfg = config_yaml_utils::CortexConfig{ .logFolderPath = default_data_folder_path.string(), + .logLlamaCppPath = kLogsLlamacppBaseName, + .logTensorrtLLMPath = kLogsTensorrtllmBaseName, + .logOnnxPath = kLogsOnnxBaseName, .dataFolderPath = default_data_folder_path.string(), .maxLogLines = config_yaml_utils::kDefaultMaxLines, .apiServerHost = config_yaml_utils::kDefaultHost,