Print errors on log when running device extractor.

This commit is contained in:
Matthias Koefferlein 2019-01-27 22:01:29 +01:00
parent 794c31329a
commit 2da7b218b4
2 changed files with 52 additions and 3 deletions

View File

@ -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 ();
}
}
}

View File

@ -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;