]> granicus.if.org Git - icinga2/commitdiff
Add path information for objects in objects file
authorGunnar Beutner <gunnar@beutner.name>
Thu, 5 Feb 2015 14:05:07 +0000 (15:05 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 5 Feb 2015 14:05:07 +0000 (15:05 +0100)
fixes #8371

lib/cli/objectlistcommand.cpp
lib/config/configitem.cpp

index 1a9b49624f6de884b79b1f3e229d211ee7d8d144..d1ed041ba039903110b3ec9e1d4e6bc129689755 100644 (file)
@@ -140,6 +140,13 @@ void ObjectListCommand::PrintObject(std::ostream& fp, bool& first, const String&
        fp << "Object '" << ConsoleColorTag(Console_ForegroundBlue | Console_Bold) << internal_name << ConsoleColorTag(Console_Normal) << "'";
        fp << " of type '" << ConsoleColorTag(Console_ForegroundMagenta | Console_Bold) << type << ConsoleColorTag(Console_Normal) << "':\n";
 
+       Array::Ptr di = object->Get("debug_info");
+
+       if (di) {
+               fp << ConsoleColorTag(Console_ForegroundCyan) << "  % declared in '" << di->Get(0) << "', lines "
+                   << di->Get(1) << ":" << di->Get(2) << "-" << di->Get(3) << ":" << di->Get(4) << ConsoleColorTag(Console_Normal) << "\n";
+       }
+
        PrintProperties(fp, properties, debug_hints, 2);
 
        type_count[type]++;
index 4f4102a5bcdbdb4b57a285f6aa4148887e8b6261..0bfcddf9420a0d5996e95d34ffbc33d93254ea30 100644 (file)
@@ -214,6 +214,14 @@ DynamicObject::Ptr ConfigItem::Commit(bool discard)
        persistentItem->Set("properties", attrs);
        persistentItem->Set("debug_hints", debugHints.ToDictionary());
 
+       Array::Ptr di = new Array();
+       di->Add(m_DebugInfo.Path);
+       di->Add(m_DebugInfo.FirstLine);
+       di->Add(m_DebugInfo.FirstColumn);
+       di->Add(m_DebugInfo.LastLine);
+       di->Add(m_DebugInfo.LastColumn);
+       persistentItem->Set("debug_info", di);
+
        ConfigCompilerContext::GetInstance()->WriteObject(persistentItem);
        persistentItem.reset();