Contextual option logging

This commit is contained in:
Marcus Holland-Moritz 2023-08-04 13:00:05 +02:00
parent 5d191a6dbf
commit a75381b0ef
2 changed files with 12 additions and 5 deletions

View File

@ -24,6 +24,7 @@
#include <iosfwd> #include <iosfwd>
#include <optional> #include <optional>
#include <span> #include <span>
#include <sstream>
#include <stdexcept> #include <stdexcept>
#include <type_traits> #include <type_traits>
#include <unordered_map> #include <unordered_map>
@ -178,6 +179,12 @@ class contextual_option_parser {
} }
} }
std::string as_string() const {
std::ostringstream oss;
dump(oss);
return oss.str();
}
private: private:
void add_contextual(typename option_type::context_type const& ctx, void add_contextual(typename option_type::context_type const& ctx,
typename option_type::value_type const& val) const { typename option_type::value_type const& val) const {

View File

@ -977,7 +977,7 @@ int mkdwarfs_main(int argc, sys_char** argv) {
contextual_option_parser cop("--order", options.inode.fragment_order, cp, contextual_option_parser cop("--order", options.inode.fragment_order, cp,
order_parser); order_parser);
cop.parse(order); cop.parse(order);
cop.dump(std::cerr); LOG_DEBUG << cop.as_string();
} catch (std::exception const& e) { } catch (std::exception const& e) {
LOG_ERROR << e.what(); LOG_ERROR << e.what();
return 1; return 1;
@ -988,7 +988,7 @@ int mkdwarfs_main(int argc, sys_char** argv) {
contextual_option_parser cop("--max-lookback-blocks", max_lookback_opt, cp, contextual_option_parser cop("--max-lookback-blocks", max_lookback_opt, cp,
max_lookback_parser); max_lookback_parser);
cop.parse(max_lookback_blocks); cop.parse(max_lookback_blocks);
cop.dump(std::cerr); LOG_DEBUG << cop.as_string();
} catch (std::exception const& e) { } catch (std::exception const& e) {
LOG_ERROR << e.what(); LOG_ERROR << e.what();
return 1; return 1;
@ -999,7 +999,7 @@ int mkdwarfs_main(int argc, sys_char** argv) {
contextual_option_parser cop("--window-size", window_size_opt, cp, contextual_option_parser cop("--window-size", window_size_opt, cp,
window_size_parser); window_size_parser);
cop.parse(window_size); cop.parse(window_size);
cop.dump(std::cerr); LOG_DEBUG << cop.as_string();
} catch (std::exception const& e) { } catch (std::exception const& e) {
LOG_ERROR << e.what(); LOG_ERROR << e.what();
return 1; return 1;
@ -1010,7 +1010,7 @@ int mkdwarfs_main(int argc, sys_char** argv) {
contextual_option_parser cop("--window-step", window_step_opt, cp, contextual_option_parser cop("--window-step", window_step_opt, cp,
window_step_parser); window_step_parser);
cop.parse(window_step); cop.parse(window_step);
cop.dump(std::cerr); LOG_DEBUG << cop.as_string();
} catch (std::exception const& e) { } catch (std::exception const& e) {
LOG_ERROR << e.what(); LOG_ERROR << e.what();
return 1; return 1;
@ -1021,7 +1021,7 @@ int mkdwarfs_main(int argc, sys_char** argv) {
contextual_option_parser cop("--compression", compression_opt, cp, contextual_option_parser cop("--compression", compression_opt, cp,
compressor_parser); compressor_parser);
cop.parse(compression); cop.parse(compression);
cop.dump(std::cerr); LOG_DEBUG << cop.as_string();
compression_opt.visit_contextual([catmgr = options.inode.categorizer_mgr]( compression_opt.visit_contextual([catmgr = options.inode.categorizer_mgr](
auto cat, block_compressor const& bc) { auto cat, block_compressor const& bc) {