From cb5bd6319449e4edd1c8f308cd5ab09e47a07731 Mon Sep 17 00:00:00 2001 From: Tobias Gloth Date: Thu, 4 Jun 2026 01:28:51 -0400 Subject: [PATCH] add "logfile" option to log diagnostics to file using boost (#13931) add some logging options Co-authored-by: SoftFever --- src/OrcaSlicer.cpp | 4 ++++ src/libslic3r/PrintConfig.cpp | 7 +++++++ src/libslic3r/Utils.hpp | 1 + src/libslic3r/utils.cpp | 5 +++++ 4 files changed, 17 insertions(+) diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index 2e445cadfd..f30550a4e3 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -1357,6 +1357,10 @@ int CLI::run(int argc, char **argv) else { set_logging_level(2); } + const ConfigOptionString* opt_logfile = m_config.opt("logfile"); + if (opt_logfile) { + set_logging_file(opt_logfile->value); + } global_begin_time = (long long)Slic3r::Utils::get_current_time_utc(); BOOST_LOG_TRIVIAL(warning) << boost::format("cli mode, Current OrcaSlicer Version %1%")%SoftFever_VERSION; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 8da03fd969..2113b78467 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -9750,6 +9750,7 @@ void DynamicPrintConfig::update_values_to_printer_extruders_for_multiple_filamen BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(", Line %1%: can not find opt define for %2%")%__LINE__%key; continue; } + switch (optdef->type) { case coStrings: { @@ -10846,6 +10847,12 @@ CLIMiscConfigDef::CLIMiscConfigDef() def->cli_params = "level"; def->set_default_value(new ConfigOptionInt(1)); + def = this->add("logfile", coInt); + def->label = L("Log file"); + def->tooltip = L("Redirects debug logging to file.\n"); + def->cli_params = "file"; + def->set_default_value(new ConfigOptionString()); + def = this->add("enable_timelapse", coBool); def->label = L("Enable timelapse for print"); def->tooltip = L("If enabled, this slicing will be considered using timelapse."); diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 95ad6ea9d2..51cb2e5787 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -79,6 +79,7 @@ namespace boost { namespace filesystem { class directory_entry; }} namespace Slic3r { extern void set_logging_level(unsigned int level); +extern void set_logging_file(const std::string &file); extern unsigned int level_string_to_boost(std::string level); extern std::string get_string_logging_level(unsigned level); extern unsigned get_logging_level(); diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 2cccfbe02b..675286d3a1 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -129,6 +129,11 @@ void set_logging_level(unsigned int level) ); } +void set_logging_file(const std::string &file) +{ + boost::log::add_file_log(file); +} + unsigned int level_string_to_boost(std::string level) { std::map Control_Param;