More consistency in command line tool behaviour

This commit is contained in:
Marcus Holland-Moritz 2021-03-31 22:50:14 +02:00
parent 8dd1385d1d
commit aec1cd924d
2 changed files with 16 additions and 9 deletions

View File

@ -105,10 +105,11 @@ int dwarfsck(int argc, char** argv) {
return 0;
}
stream_logger lgr(std::cerr, logger::parse_level(log_level));
LOG_PROXY(debug_logger_policy, lgr);
try {
auto level = logger::parse_level(log_level);
stream_logger lgr(std::cerr, level, level >= logger::DEBUG);
LOG_PROXY(debug_logger_policy, lgr);
filesystem_options fsopts;
fsopts.metadata.check_consistency = true;
@ -149,13 +150,13 @@ int dwarfsck(int argc, char** argv) {
}
}
} catch (system_error const& e) {
LOG_ERROR << folly::exceptionStr(e);
std::cerr << folly::exceptionStr(e) << std::endl;
return 1;
} catch (runtime_error const& e) {
LOG_ERROR << folly::exceptionStr(e);
std::cerr << folly::exceptionStr(e) << std::endl;
return 1;
} catch (std::system_error const& e) {
LOG_ERROR << folly::exceptionStr(e);
std::cerr << folly::exceptionStr(e) << std::endl;
return 1;
}

View File

@ -27,6 +27,8 @@
#include <boost/program_options.hpp>
#include <folly/String.h>
#include "dwarfs/filesystem_extractor.h"
#include "dwarfs/filesystem_v2.h"
#include "dwarfs/logger.h"
@ -91,7 +93,8 @@ int dwarfsextract(int argc, char** argv) {
}
try {
stream_logger lgr(std::cerr, logger::parse_level(log_level));
auto level = logger::parse_level(log_level);
stream_logger lgr(std::cerr, level, level >= logger::DEBUG);
filesystem_options fsopts;
try {
fsopts.image_offset = image_offset == "auto"
@ -131,10 +134,13 @@ int dwarfsextract(int argc, char** argv) {
fsx.close();
} catch (runtime_error const& e) {
std::cerr << "error: " << e.what() << std::endl;
std::cerr << folly::exceptionStr(e) << std::endl;
return 1;
} catch (system_error const& e) {
std::cerr << "error: " << e.what() << std::endl;
std::cerr << folly::exceptionStr(e) << std::endl;
return 1;
} catch (std::system_error const& e) {
std::cerr << folly::exceptionStr(e) << std::endl;
return 1;
}