From 2da7b218b48c71b20fc42fc54c421ce96a301597 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 27 Jan 2019 22:01:29 +0100 Subject: [PATCH] Print errors on log when running device extractor. --- src/db/db/dbNetlistDeviceExtractor.cc | 50 +++++++++++++++++++++++++-- src/db/db/dbNetlistDeviceExtractor.h | 5 +++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/db/db/dbNetlistDeviceExtractor.cc b/src/db/db/dbNetlistDeviceExtractor.cc index a0d40cb31..3edbf16bd 100644 --- a/src/db/db/dbNetlistDeviceExtractor.cc +++ b/src/db/db/dbNetlistDeviceExtractor.cc @@ -27,6 +27,7 @@ #include "tlProgress.h" #include "tlTimer.h" +#include "tlInternational.h" namespace db { @@ -45,6 +46,31 @@ NetlistDeviceExtractorError::NetlistDeviceExtractorError (const std::string &cel // .. nothing yet .. } +std::string NetlistDeviceExtractorError::to_string () const +{ + std::string res; + + if (! m_category_name.empty ()) { + if (m_category_description.empty ()) { + res += "[" + m_category_name + "] "; + } else { + res += "[" + m_category_description + "] "; + } + } + + res += m_message; + + if (! m_cell_name.empty ()) { + res += tl::to_string (tr (", in cell: ")) + m_cell_name; + } + + if (! m_geometry.box ().empty ()) { + res += tl::to_string (tr (", shape: ")) + m_geometry.to_string (); + } + + return res; +} + // ---------------------------------------------------------------------------------------- // NetlistDeviceExtractor implementation @@ -485,25 +511,43 @@ std::string NetlistDeviceExtractor::cell_name () const void NetlistDeviceExtractor::error (const std::string &msg) { m_errors.push_back (db::NetlistDeviceExtractorError (cell_name (), msg)); + + if (tl::verbosity () >= 20) { + tl::error << m_errors.back ().to_string (); + } } void NetlistDeviceExtractor::error (const std::string &msg, const db::DPolygon &poly) { - error (msg); + m_errors.push_back (db::NetlistDeviceExtractorError (cell_name (), msg)); m_errors.back ().set_geometry (poly); + + if (tl::verbosity () >= 20) { + tl::error << m_errors.back ().to_string (); + } } void NetlistDeviceExtractor::error (const std::string &category_name, const std::string &category_description, const std::string &msg) { - error (msg); + m_errors.push_back (db::NetlistDeviceExtractorError (cell_name (), msg)); m_errors.back ().set_category_name (category_name); m_errors.back ().set_category_description (category_description); + + if (tl::verbosity () >= 20) { + tl::error << m_errors.back ().to_string (); + } } void NetlistDeviceExtractor::error (const std::string &category_name, const std::string &category_description, const std::string &msg, const db::DPolygon &poly) { - error (category_name, category_description, msg); + m_errors.push_back (db::NetlistDeviceExtractorError (cell_name (), msg)); + m_errors.back ().set_category_name (category_name); + m_errors.back ().set_category_description (category_description); m_errors.back ().set_geometry (poly); + + if (tl::verbosity () >= 20) { + tl::error << m_errors.back ().to_string (); + } } } diff --git a/src/db/db/dbNetlistDeviceExtractor.h b/src/db/db/dbNetlistDeviceExtractor.h index cbd8ec85a..c82e189d4 100644 --- a/src/db/db/dbNetlistDeviceExtractor.h +++ b/src/db/db/dbNetlistDeviceExtractor.h @@ -138,6 +138,11 @@ public: m_cell_name = n; } + /** + * @brief Formats this message for printing + */ + std::string to_string () const; + private: std::string m_cell_name; std::string m_message;