mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Option for realtime logging with -vv
This commit is contained in:
@@ -174,6 +174,11 @@ std::vector<IfcGeom::filter_t> setup_filters(const std::vector<geom_filter>&, co
|
||||
|
||||
bool init_input_file(const std::string& filename, IfcParse::IfcFile*& ifc_file, bool no_progress, bool mmap);
|
||||
|
||||
// from https://stackoverflow.com/questions/31696328/boost-program-options-using-zero-parameter-options-multiple-times
|
||||
struct verbosity_counter {
|
||||
int count;
|
||||
};
|
||||
|
||||
#if defined(_MSC_VER) && defined(_UNICODE)
|
||||
int wmain(int argc, wchar_t** argv) {
|
||||
typedef po::wcommand_line_parser command_line_parser;
|
||||
@@ -197,10 +202,11 @@ int main(int argc, char** argv) {
|
||||
std::string log_format;
|
||||
|
||||
po::options_description generic_options("Command line options");
|
||||
verbosity_counter vcounter;
|
||||
generic_options.add_options()
|
||||
("help,h", "display usage information")
|
||||
("version", "display version information")
|
||||
("verbose,v", "more verbose log messages")
|
||||
("verbose,v", po::value(&vcounter)->zero_tokens(), "more verbose log messages")
|
||||
("quiet,q", "less status and progress output")
|
||||
("stderr-progress", "output progress to stderr stream")
|
||||
("yes,y", "answer 'yes' automatically to possible confirmation queries (e.g. overwriting an existing output file)")
|
||||
@@ -403,7 +409,6 @@ int main(int argc, char** argv) {
|
||||
po::notify(vmap);
|
||||
|
||||
const bool mmap = vmap.count("mmap") != 0;
|
||||
const bool verbose = vmap.count("verbose") != 0;
|
||||
const bool no_progress = vmap.count("no-progress") != 0;
|
||||
const bool quiet = vmap.count("quiet") != 0;
|
||||
const bool stderr_progress = vmap.count("stderr-progress") != 0;
|
||||
@@ -539,8 +544,13 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
Logger::SetOutput(quiet ? nullptr : &cout_, &log_stream);
|
||||
Logger::Verbosity(verbose ? Logger::LOG_NOTICE : Logger::LOG_ERROR);
|
||||
Logger::SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream);
|
||||
Logger::Verbosity(vcounter.count
|
||||
? (vcounter.count > 1
|
||||
? Logger::LOG_DEBUG
|
||||
: Logger::LOG_NOTICE)
|
||||
: Logger::LOG_ERROR
|
||||
);
|
||||
|
||||
path_t output_temp_filename = output_filename + IfcUtil::path::from_utf8(TEMP_FILE_EXTENSION);
|
||||
|
||||
@@ -757,7 +767,7 @@ int main(int argc, char** argv) {
|
||||
Logger::Status("Creating geometry...");
|
||||
}
|
||||
|
||||
Logger::SetOutput(quiet ? nullptr : &cout_, &log_stream);
|
||||
Logger::SetOutput(quiet ? nullptr : &cout_, vcounter.count > 1 ? &cout_ : &log_stream);
|
||||
|
||||
if (model_rotation) {
|
||||
std::array<double, 4> &rotation = settings.rotation;
|
||||
@@ -913,6 +923,9 @@ int main(int argc, char** argv) {
|
||||
cout_ << std::flush;
|
||||
if (stderr_progress)
|
||||
cerr_ << std::flush;
|
||||
} else if (vcounter.count == 2) {
|
||||
const int progress = context_iterator.progress();
|
||||
Logger::Message(Logger::LOG_DEBUG, "Progress " + boost::lexical_cast<std::string>(progress));
|
||||
} else {
|
||||
const int progress = context_iterator.progress() / 2;
|
||||
if (old_progress != progress) Logger::ProgressBar(progress);
|
||||
@@ -1119,6 +1132,11 @@ void parse_filter(geom_filter &filter, const std::vector<std::string>& values)
|
||||
filter.values.insert(values.begin() + (filter.type == geom_filter::ENTITY_ARG ? 2 : 1), values.end());
|
||||
}
|
||||
|
||||
void validate(boost::any& v, const std::vector<std::string>& values, verbosity_counter*, long) {
|
||||
if (v.empty()) v = verbosity_counter{ 1 };
|
||||
else ++boost::any_cast<verbosity_counter&>(v).count;
|
||||
}
|
||||
|
||||
void validate(boost::any& v, const std::vector<std::string>& values, inclusion_filter*, int)
|
||||
{
|
||||
/// @todo For now only single --include, --include+, --exclude, or --exclude+ supported. Support having multiple.
|
||||
|
||||
@@ -37,14 +37,14 @@ namespace {
|
||||
|
||||
template <typename T>
|
||||
struct severity_strings {
|
||||
static const std::array<std::basic_string<T>, 3> value;
|
||||
static const std::array<std::basic_string<T>, 4> value;
|
||||
};
|
||||
|
||||
template <>
|
||||
const std::array<std::basic_string<char>, 3> severity_strings<char>::value = { "Notice", "Warning", "Error" };
|
||||
const std::array<std::basic_string<char>, 4> severity_strings<char>::value = { "Debug", "Notice", "Warning", "Error" };
|
||||
|
||||
template <>
|
||||
const std::array<std::basic_string<wchar_t>, 3> severity_strings<wchar_t>::value = { L"Notice", L"Warning", L"Error" };
|
||||
const std::array<std::basic_string<wchar_t>, 4> severity_strings<wchar_t>::value = { L"Debug", L"Notice", L"Warning", L"Error" };
|
||||
|
||||
template <typename T>
|
||||
void plain_text_message(T& os, const boost::optional<IfcUtil::IfcBaseClass*>& current_product, Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseClass* instance) {
|
||||
@@ -93,6 +93,9 @@ namespace {
|
||||
}
|
||||
|
||||
void Logger::SetProduct(boost::optional<IfcUtil::IfcBaseClass*> product) {
|
||||
if (verbosity == LOG_DEBUG && product) {
|
||||
Message(LOG_DEBUG, "Begin processing", *product);
|
||||
}
|
||||
current_product = product;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
class IFC_PARSE_API Logger {
|
||||
public:
|
||||
typedef enum { LOG_NOTICE, LOG_WARNING, LOG_ERROR } Severity;
|
||||
typedef enum { LOG_DEBUG, LOG_NOTICE, LOG_WARNING, LOG_ERROR } Severity;
|
||||
typedef enum { FMT_PLAIN, FMT_JSON } Format;
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user