Matt Spinler | 8c686cc | 2019-09-20 13:46:02 -0500 | [diff] [blame] | 1 | #include "severity.hpp" |
| 2 | |
| 3 | namespace openpower |
| 4 | { |
| 5 | namespace pels |
| 6 | { |
| 7 | |
| 8 | using LogSeverity = phosphor::logging::Entry::Level; |
| 9 | |
| 10 | /** |
| 11 | * @brief The major types of severity values, based on the |
| 12 | * the left nibble of the severity value. |
| 13 | */ |
| 14 | enum class PELSeverityType : uint8_t |
| 15 | { |
| 16 | nonError = 0x00, |
| 17 | recovered = 0x10, |
| 18 | predictive = 0x20, |
| 19 | unrecoverable = 0x40, |
| 20 | critical = 0x50, |
| 21 | diagnostic = 0x60, |
| 22 | symptom = 0x70 |
| 23 | }; |
| 24 | |
| 25 | uint8_t convertOBMCSeverityToPEL(LogSeverity severity) |
| 26 | { |
| 27 | uint8_t pelSeverity = static_cast<uint8_t>(PELSeverityType::unrecoverable); |
| 28 | switch (severity) |
| 29 | { |
| 30 | case (LogSeverity::Notice): |
| 31 | case (LogSeverity::Informational): |
| 32 | case (LogSeverity::Debug): |
| 33 | pelSeverity = static_cast<uint8_t>(PELSeverityType::nonError); |
| 34 | break; |
| 35 | |
| 36 | case (LogSeverity::Warning): |
| 37 | pelSeverity = static_cast<uint8_t>(PELSeverityType::predictive); |
| 38 | break; |
| 39 | |
| 40 | case (LogSeverity::Critical): |
| 41 | pelSeverity = static_cast<uint8_t>(PELSeverityType::critical); |
| 42 | break; |
| 43 | |
| 44 | case (LogSeverity::Emergency): |
| 45 | case (LogSeverity::Alert): |
| 46 | case (LogSeverity::Error): |
| 47 | pelSeverity = static_cast<uint8_t>(PELSeverityType::unrecoverable); |
| 48 | break; |
| 49 | } |
| 50 | |
| 51 | return pelSeverity; |
| 52 | } |
| 53 | } // namespace pels |
| 54 | } // namespace openpower |