From f296fdfbed71e900a3e0d6579673960e6a560654 Mon Sep 17 00:00:00 2001 From: rankaiyx Date: Wed, 8 Jul 2026 15:45:28 +0800 Subject: [PATCH] common: auto-create prompts-log-dir at argument parsing, so all tools using the flag benefit (#25322) --- common/arg.cpp | 8 +++++++- tools/server/README.md | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common/arg.cpp b/common/arg.cpp index fdf58614b6..a260931992 100644 --- a/common/arg.cpp +++ b/common/arg.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -3451,9 +3452,14 @@ common_params_context common_params_parser_init(common_params & params, llama_ex ).set_env("LLAMA_ARG_LOG_FILE")); add_opt(common_arg( {"--log-prompts-dir"}, "PATH", - "Log prompts to directory (only used for debugging, default: disabled)", + "Log prompts to directory (auto-created if not present; only used for debugging, default: disabled)", [](common_params & params, const std::string & value) { params.path_prompts_log_dir = value; + std::error_code ec; + std::filesystem::create_directories(value, ec); + if (ec) { + fprintf(stderr, "warning: failed to create prompts-log-dir '%s': %s\n", value.c_str(), ec.message().c_str()); + } } ).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI})); add_opt(common_arg( diff --git a/tools/server/README.md b/tools/server/README.md index 501b66123d..365a944659 100644 --- a/tools/server/README.md +++ b/tools/server/README.md @@ -228,7 +228,7 @@ For the full list of features, please refer to [server's changelog](https://gith | `-sps, --slot-prompt-similarity SIMILARITY` | how much the prompt of a request must match the prompt of a slot in order to use that slot (default: 0.10, 0.0 = disabled) | | `--lora-init-without-apply` | load LoRA adapters without applying them (apply later via POST /lora-adapters) (default: disabled) | | `--sleep-idle-seconds SECONDS` | number of seconds of idleness after which the server will sleep (default: -1; -1 = disabled) | -| `--log-prompts-dir PATH` | Log prompts to directory (only used for debugging, default: disabled) | +| `--log-prompts-dir PATH` | Log prompts to directory (auto-created if not present; only used for debugging, default: disabled) | | `--spec-draft-hf, -hfd, -hfrd, --hf-repo-draft /[:quant]` | Same as --hf-repo, but for the draft model (default: unused)
(env: LLAMA_ARG_SPEC_DRAFT_HF_REPO) | | `--spec-draft-threads, -td, --threads-draft N` | number of threads to use during generation (default: same as --threads) | | `--spec-draft-threads-batch, -tbd, --threads-batch-draft N` | number of threads to use during batch and prompt processing (default: same as --threads-draft) |