From 84eebfc7291bbd7a748755c25f9adaa5e1841545 Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Mon, 13 Feb 2023 15:28:37 +0800 Subject: [PATCH] ENH: refine log level for cli Change-Id: I781319ae85bff77f58931689f589b53e0e778389 --- src/BambuStudio.cpp | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/BambuStudio.cpp b/src/BambuStudio.cpp index 8222a3956..5e61e50ac 100644 --- a/src/BambuStudio.cpp +++ b/src/BambuStudio.cpp @@ -334,7 +334,7 @@ int CLI::run(int argc, char **argv) // startup if gtk3 is used. This env var has to be set explicitly to // instruct the window manager to fall back to X server mode. ::setenv("GDK_BACKEND", "x11", /* replace */ true); - + // Also on Linux, we need to tell Xlib that we will be using threads, // lest we crash when we fire up GStreamer. XInitThreads(); @@ -457,6 +457,15 @@ int CLI::run(int argc, char **argv) return (argc == 0) ? 0 : 1; #endif // SLIC3R_GUI } + else { + const ConfigOptionInt *opt_loglevel = m_config.opt("debug"); + if (opt_loglevel) { + set_logging_level(opt_loglevel->value); + } + else { + set_logging_level(2); + } + } BOOST_LOG_TRIVIAL(info) << "start_gui="<< start_gui << std::endl; @@ -2328,17 +2337,6 @@ int CLI::run(int argc, char **argv) bool CLI::setup(int argc, char **argv) { - { - Slic3r::set_logging_level(1); - const char *loglevel = boost::nowide::getenv("BBL_LOGLEVEL"); - if (loglevel != nullptr) { - if (loglevel[0] >= '0' && loglevel[0] <= '9' && loglevel[1] == 0) - set_logging_level(loglevel[0] - '0'); - else - boost::nowide::cerr << "Invalid BBL_LOGLEVEL environment variable: " << loglevel << std::endl; - } - } - // Detect the operating system flavor after SLIC3R_LOGLEVEL is set. detect_platform(); @@ -2406,15 +2404,6 @@ bool CLI::setup(int argc, char **argv) m_transforms.emplace_back(opt_key); } -#if !BBL_RELEASE_TO_PUBLIC - { - const ConfigOptionInt *opt_loglevel = m_config.opt("debug"); - if (opt_loglevel != 0) { - set_logging_level(opt_loglevel->value); - } - } -#endif - //FIXME Validating at this stage most likely does not make sense, as the config is not fully initialized yet. std::string validity = m_config.validate();