command: Setup logging before attempting to create Context
This way errors (such as an invalid package type) occurring during Context creation are printed properly. Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
parent
e76479f379
commit
7f69c0f455
@ -77,6 +77,20 @@ bool CommandHandler::executeBeforeContext()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
validate();
|
validate();
|
||||||
|
|
||||||
|
if (vm.count("quiet")) {
|
||||||
|
log_streams.push_back(std::make_pair(&std::cerr, LogLevel::WARNING_MSG));
|
||||||
|
} else {
|
||||||
|
log_streams.push_back(std::make_pair(&std::cerr, LogLevel::LOG_MSG));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm.count("log")) {
|
||||||
|
std::string logfilename = vm["log"].as<std::string>();
|
||||||
|
logfile = std::ofstream(logfilename);
|
||||||
|
if (!logfile)
|
||||||
|
log_error("Failed to open log file '%s' for writing.\n", logfilename.c_str());
|
||||||
|
log_streams.push_back(std::make_pair(&logfile, LogLevel::LOG_MSG));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,20 +144,6 @@ void CommandHandler::setupContext(Context *ctx)
|
|||||||
ctx->debug = true;
|
ctx->debug = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("quiet")) {
|
|
||||||
log_streams.push_back(std::make_pair(&std::cerr, LogLevel::WARNING_MSG));
|
|
||||||
} else {
|
|
||||||
log_streams.push_back(std::make_pair(&std::cerr, LogLevel::LOG_MSG));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vm.count("log")) {
|
|
||||||
std::string logfilename = vm["log"].as<std::string>();
|
|
||||||
logfile = std::ofstream(logfilename);
|
|
||||||
if (!logfile)
|
|
||||||
log_error("Failed to open log file '%s' for writing.\n", logfilename.c_str());
|
|
||||||
log_streams.push_back(std::make_pair(&logfile, LogLevel::LOG_MSG));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vm.count("force")) {
|
if (vm.count("force")) {
|
||||||
ctx->force = true;
|
ctx->force = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user