Add function to read code version

Read the BMC code version once at startup.  This will
be added to error logs in future commits.

The code is getting the version from a file instead
of from D-Bus in order to reduce dependencies.

Tested: Call the function and check that it returned the
        correct thing.

Change-Id: I9a4729e946a130ec32c375c283fd22a7658121f5
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/log_manager.cpp b/log_manager.cpp
index 6717a7a..641ed7b 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -446,6 +446,31 @@
     return;
 }
 
+std::string Manager::readFWVersion()
+{
+    std::string version;
+    std::ifstream versionFile{BMC_VERSION_FILE};
+    std::string line;
+    static constexpr auto VERSION_ID = "VERSION_ID=";
+
+    while (std::getline(versionFile, line))
+    {
+        if (line.find(VERSION_ID) != std::string::npos)
+        {
+            auto pos = line.find_first_of('"') + 1;
+            version = line.substr(pos, line.find_last_of('"') - pos);
+            break;
+        }
+    }
+
+    if (version.empty())
+    {
+        log<level::ERR>("Unable to read BMC firmware version");
+    }
+
+    return version;
+}
+
 } // namespace internal
 } // namespace logging
 } // namepsace phosphor