blob: 2c7c9dff1e046484af8ca406643c46eeeb1e63ad [file] [log] [blame]
Matt Spinler711d51d2019-11-06 09:36:51 -06001/**
2 * Copyright © 2019 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Matt Spinler8c686cc2019-09-20 13:46:02 -050016#include "severity.hpp"
17
Matt Spinlera7525aa2019-11-01 11:11:07 -050018#include "pel_types.hpp"
19
Matt Spinler8c686cc2019-09-20 13:46:02 -050020namespace openpower
21{
22namespace pels
23{
24
25using LogSeverity = phosphor::logging::Entry::Level;
26
Matt Spinler8c686cc2019-09-20 13:46:02 -050027uint8_t convertOBMCSeverityToPEL(LogSeverity severity)
28{
Matt Spinlera7525aa2019-11-01 11:11:07 -050029 uint8_t pelSeverity = static_cast<uint8_t>(SeverityType::unrecoverable);
Matt Spinler8c686cc2019-09-20 13:46:02 -050030 switch (severity)
31 {
32 case (LogSeverity::Notice):
33 case (LogSeverity::Informational):
34 case (LogSeverity::Debug):
Matt Spinlera7525aa2019-11-01 11:11:07 -050035 pelSeverity = static_cast<uint8_t>(SeverityType::nonError);
Matt Spinler8c686cc2019-09-20 13:46:02 -050036 break;
37
38 case (LogSeverity::Warning):
Matt Spinlera7525aa2019-11-01 11:11:07 -050039 pelSeverity = static_cast<uint8_t>(SeverityType::predictive);
Matt Spinler8c686cc2019-09-20 13:46:02 -050040 break;
41
42 case (LogSeverity::Critical):
Matt Spinlera7525aa2019-11-01 11:11:07 -050043 pelSeverity = static_cast<uint8_t>(SeverityType::critical);
Matt Spinler8c686cc2019-09-20 13:46:02 -050044 break;
45
46 case (LogSeverity::Emergency):
47 case (LogSeverity::Alert):
48 case (LogSeverity::Error):
Matt Spinlera7525aa2019-11-01 11:11:07 -050049 pelSeverity = static_cast<uint8_t>(SeverityType::unrecoverable);
Matt Spinler8c686cc2019-09-20 13:46:02 -050050 break;
51 }
52
53 return pelSeverity;
54}
55} // namespace pels
56} // namespace openpower