Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Ben Tyner | 1b1915e | 2020-10-23 15:13:38 -0500 | [diff] [blame] | 3 | #include <util/ffdc_file.hpp> |
| 4 | |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 5 | #include <cstddef> // for size_t |
| 6 | #include <map> |
| 7 | #include <string> |
Ben Tyner | 1b1915e | 2020-10-23 15:13:38 -0500 | [diff] [blame] | 8 | #include <vector> |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 9 | |
| 10 | namespace attn |
| 11 | { |
| 12 | |
| 13 | /** @brief Logging level types */ |
| 14 | enum level |
| 15 | { |
| 16 | INFO |
| 17 | }; |
| 18 | |
| 19 | /** @brief Logging event types */ |
| 20 | enum class EventType |
| 21 | { |
| 22 | Checkstop = 0, |
| 23 | Terminate = 1, |
| 24 | Vital = 2, |
| 25 | HwDiagsFail = 3, |
| 26 | AttentionFail = 4 |
| 27 | }; |
| 28 | |
| 29 | /** @brief Maximum length of a single trace event message */ |
| 30 | static const size_t trace_msg_max_len = 255; |
| 31 | |
| 32 | /** @brief create trace message */ |
| 33 | template <level L> |
| 34 | void trace(const char* i_message); |
| 35 | |
| 36 | /** @brief commit checkstop event to log */ |
| 37 | void eventCheckstop(std::map<std::string, std::string>& i_errors); |
| 38 | |
| 39 | /** @brief commit special attention TI event to log */ |
Ben Tyner | 4071772 | 2020-09-23 09:43:20 -0500 | [diff] [blame] | 40 | void eventTerminate(std::map<std::string, std::string> i_additionalData); |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 41 | |
| 42 | /** @brief commit SBE vital event to log */ |
| 43 | void eventVital(); |
| 44 | |
| 45 | /** @brief commit analyzer failure event to log */ |
| 46 | void eventHwDiagsFail(int i_error); |
| 47 | |
| 48 | /** @brief commit attention handler failure event to log */ |
| 49 | void eventAttentionFail(int i_error); |
| 50 | |
Ben Tyner | 1b1915e | 2020-10-23 15:13:38 -0500 | [diff] [blame] | 51 | using FFDCTuple = |
| 52 | std::tuple<util::FFDCFormat, uint8_t, uint8_t, sdbusplus::message::unix_fd>; |
| 53 | |
| 54 | /** |
| 55 | * Create an FFDCFile object containing the specified lines of text data. |
| 56 | * |
| 57 | * Throws an exception if an error occurs. |
| 58 | * |
| 59 | * @param lines lines of text data to write to file |
| 60 | * @return FFDCFile object |
| 61 | */ |
| 62 | util::FFDCFile createFFDCFile(const std::vector<std::string>& lines); |
| 63 | |
| 64 | /** |
| 65 | * Create FFDCFile objects containing debug data to store in the error log. |
| 66 | * |
| 67 | * If an error occurs, the error is written to the journal but an exception |
| 68 | * is not thrown. |
| 69 | * |
| 70 | * @param journal system journal |
| 71 | * @return vector of FFDCFile objects |
| 72 | */ |
| 73 | std::vector<util::FFDCFile> createFFDCFiles(); |
| 74 | |
| 75 | /** |
| 76 | * Create FFDCTuple objects corresponding to the specified FFDC files. |
| 77 | * |
| 78 | * The D-Bus method to create an error log requires a vector of tuples to |
| 79 | * pass in the FFDC file information. |
| 80 | * |
| 81 | * @param files FFDC files |
| 82 | * @return vector of FFDCTuple objects |
| 83 | */ |
| 84 | std::vector<FFDCTuple> createFFDCTuples(std::vector<util::FFDCFile>& files); |
| 85 | |
Ben Tyner | b1ebfcb | 2020-05-08 18:52:48 -0500 | [diff] [blame] | 86 | } // namespace attn |