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/include/logger.hpp b/vpd-manager/include/logger.hpp
index 1980b2b..ec63de7 100644
--- a/vpd-manager/include/logger.hpp
+++ b/vpd-manager/include/logger.hpp
@@ -308,16 +308,7 @@
const std::source_location& i_location =
std::source_location::current());
- /**
- * @brief API to initiate VPD collection logging.
- *
- * This API initiates VPD collection logging. It checks for existing
- * collection log files and if 3 such files are found, it deletes the oldest
- * file and initiates a VPD collection logger object, so that every new VPD
- * collection flow always gets logged into a new file.
- */
- void initiateVpdCollectionLogging() noexcept;
-
+#ifdef ENABLE_FILE_LOGGING
/**
* @brief API to terminate VPD collection logging.
*
@@ -328,21 +319,40 @@
{
m_collectionLogger.reset();
}
+#endif
private:
/**
* @brief Constructor
*/
- Logger() : m_vpdWriteLogger(nullptr), m_collectionLogger(nullptr) {}
+ Logger() : m_vpdWriteLogger(nullptr)
+ {
+#ifdef ENABLE_FILE_LOGGING
+ m_collectionLogger = nullptr;
+#endif
+ }
+
+#ifdef ENABLE_FILE_LOGGING
+ /**
+ * @brief API to initiate VPD collection logging.
+ *
+ * This API initiates VPD collection logging. It checks for existing
+ * collection log files and if 3 such files are found, it deletes the oldest
+ * file and initiates a VPD collection logger object, so that every new VPD
+ * collection flow always gets logged into a new file.
+ */
+ void initiateVpdCollectionLogging() noexcept;
+
+ // logger object to handle VPD collection logs
+ std::unique_ptr<ILogFileHandler> m_collectionLogger;
+
+#endif
// Instance to the logger class.
static std::shared_ptr<Logger> m_loggerInstance;
// logger object to handle VPD write logs
std::unique_ptr<ILogFileHandler> m_vpdWriteLogger;
-
- // logger object to handle VPD collection logs
- std::unique_ptr<ILogFileHandler> m_collectionLogger;
};
/**