Flag based logger functions

Moved initiation and termination of FRU VPD collection logging under
compile time flag. User can decide whether to log in a file or journal
while building the bmc image by setting/unsetting the particular flag.

Test:
Image loaded on a rainier system
- ls /var/lib/vpd/ - initially there was 1 collection log file
- Called CollectFRUVPD
- ls /var/lib/vpd/ - there were 2 collection log file
- Called CollectFRUVPD
- ls /var/lib/vpd/ - there were 3 collection log file
- Called CollectFRUVPD
- ls /var/lib/vpd/ - there were 3 collection log file, as max no is 3

Change-Id: I63238d63bea065f6b1c0fca6d66c87307a713f94
Signed-off-by: Alpana Kumari <alpu8007@gmail.com>
diff --git a/vpd-manager/src/logger.cpp b/vpd-manager/src/logger.cpp
index 504c3b2..8411aa2 100644
--- a/vpd-manager/src/logger.cpp
+++ b/vpd-manager/src/logger.cpp
@@ -16,11 +16,27 @@
     l_log << "FileName: " << i_location.file_name() << ","
           << " Line: " << i_location.line() << " " << i_message;
 
-    if ((i_placeHolder == PlaceHolder::COLLECTION) && m_collectionLogger)
+    if (i_placeHolder == PlaceHolder::COLLECTION)
     {
 #ifdef ENABLE_FILE_LOGGING
-        // Log it to a specific place.
-        m_collectionLogger->logMessage(l_log.str());
+        if (m_collectionLogger.get() == nullptr)
+        {
+            initiateVpdCollectionLogging();
+
+            if (m_collectionLogger.get() != nullptr)
+            {
+                // Log it to a specific place.
+                m_collectionLogger->logMessage(l_log.str());
+            }
+            else
+            {
+                std::cout << l_log.str() << std::endl;
+            }
+        }
+        else
+        {
+            m_collectionLogger->logMessage(l_log.str());
+        }
 #else
         std::cout << l_log.str() << std::endl;
 #endif
@@ -53,6 +69,7 @@
     }
 }
 
+#ifdef ENABLE_FILE_LOGGING
 void Logger::initiateVpdCollectionLogging() noexcept
 {
     try
@@ -144,6 +161,7 @@
                    std::string(l_ex.what()));
     }
 }
+#endif
 
 void SyncFileLogger::logMessage(const std::string_view& i_message)
 {