Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 1 | #include "logger.hpp" |
| 2 | |
| 3 | #include <sstream> |
| 4 | |
| 5 | namespace vpd |
| 6 | { |
Sunny Srivastava | 5779d97 | 2025-08-08 01:45:23 -0500 | [diff] [blame^] | 7 | std::shared_ptr<Logger> Logger::m_loggerInstance; |
| 8 | |
| 9 | void Logger::logMessage(std::string_view i_message, |
| 10 | const PlaceHolder& i_placeHolder, |
| 11 | const types::PelInfoTuple* i_pelTuple, |
| 12 | const std::source_location& i_location) |
| 13 | { |
| 14 | std::ostringstream l_log; |
| 15 | l_log << "FileName: " << i_location.file_name() << "," |
| 16 | << " Line: " << i_location.line() << " " << i_message; |
| 17 | |
| 18 | if (i_placeHolder == PlaceHolder::COLLECTION) |
| 19 | { |
| 20 | // Log it to a specific place. |
| 21 | m_logFileHandler->writeLogToFile(i_placeHolder); |
| 22 | } |
| 23 | else if (i_placeHolder == PlaceHolder::PEL) |
| 24 | { |
| 25 | if (i_pelTuple) |
| 26 | { |
| 27 | // LOG PEL |
| 28 | // This should call create PEL API from the event logger. |
| 29 | return; |
| 30 | } |
| 31 | std::cout << "Pel info tuple required to log PEL for message <" + |
| 32 | l_log.str() + ">" |
| 33 | << std::endl; |
| 34 | } |
| 35 | else |
| 36 | { |
| 37 | // Default case, let it go to journal. |
| 38 | std::cout << l_log.str() << std::endl; |
| 39 | } |
| 40 | } |
| 41 | |
Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 42 | namespace logging |
| 43 | { |
| 44 | void logMessage(std::string_view message, const std::source_location& location) |
| 45 | { |
| 46 | std::ostringstream log; |
| 47 | log << "FileName: " << location.file_name() << "," |
| 48 | << " Line: " << location.line() << " " << message; |
| 49 | |
Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 50 | std::cout << log.str() << std::endl; |
| 51 | } |
| 52 | } // namespace logging |
| 53 | } // namespace vpd |