mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-18 03:19:53 +00:00
Pass around non-static logger instances and programmatic access to messages in-memory
This commit is contained in:
@@ -64,13 +64,15 @@ namespace ifcopenshell {
|
||||
protected:
|
||||
std::string geometry_library_;
|
||||
Settings settings_;
|
||||
Logger& logger_;
|
||||
public:
|
||||
bool propagate_exceptions = false;
|
||||
bool partial_success_is_success = true;
|
||||
|
||||
AbstractKernel(const std::string& geometry_library, const Settings& settings)
|
||||
AbstractKernel(const std::string& geometry_library, const Settings& settings, Logger& logger = Logger::Root())
|
||||
: geometry_library_(geometry_library)
|
||||
, settings_(settings) {}
|
||||
, settings_(settings)
|
||||
, logger_(logger) {}
|
||||
|
||||
virtual ~AbstractKernel() = default;
|
||||
|
||||
@@ -79,6 +81,7 @@ namespace ifcopenshell {
|
||||
const std::string& geometry_library() const {
|
||||
return geometry_library_;
|
||||
}
|
||||
Logger& logger() const { return logger_; }
|
||||
|
||||
virtual bool supports_boolean_operations() const = 0;
|
||||
|
||||
@@ -154,7 +157,7 @@ namespace {
|
||||
if (item->instance) {
|
||||
created_from = " (created from " + item->instance->declaration().name() + ")";
|
||||
}
|
||||
Logger::Error("UNS", 1, "No support for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
|
||||
kernel->logger().Error("UNS", 1, "No support for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -178,7 +181,7 @@ namespace {
|
||||
if (item->instance) {
|
||||
created_from = " (created from " + item->instance->declaration().name() + ")";
|
||||
}
|
||||
Logger::Error("UNS", 2, "No support (after considering item upgrade) for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
|
||||
kernel->logger().Error("UNS", 2, "No support (after considering item upgrade) for " + ifcopenshell::geometry::taxonomy::kind_to_string(item->kind()) + created_from + " in kernel " + kernel->geometry_library());
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -214,7 +217,7 @@ namespace {
|
||||
template <typename T>
|
||||
struct dispatch_curve_creation<T, ifcopenshell::geometry::taxonomy::curves::max> {
|
||||
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) {
|
||||
Logger::Error("GEO", 28, "No conversion for " + std::to_string(item->kind()));
|
||||
Logger::Root().Error("GEO", 28, "No conversion for " + std::to_string(item->kind()));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -236,10 +239,10 @@ namespace {
|
||||
template <typename T>
|
||||
struct dispatch_surface_creation<T, ifcopenshell::geometry::taxonomy::surfaces::max> {
|
||||
static bool dispatch(const ifcopenshell::geometry::taxonomy::ptr& item, T&) {
|
||||
Logger::Error("GEO", 29, "No conversion for " + std::to_string(item->kind()));
|
||||
Logger::Root().Error("GEO", 29, "No conversion for " + std::to_string(item->kind()));
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user