blob: 8b5feba435113bd522e66aae5ef23f0123c70dff [file] [log] [blame]
Ben Tynerb1ebfcb2020-05-08 18:52:48 -05001#pragma once
2
Ben Tyner1b1915e2020-10-23 15:13:38 -05003#include <util/ffdc_file.hpp>
4
Ben Tynerb1ebfcb2020-05-08 18:52:48 -05005#include <cstddef> // for size_t
6#include <map>
7#include <string>
Ben Tyner1b1915e2020-10-23 15:13:38 -05008#include <vector>
Ben Tynerb1ebfcb2020-05-08 18:52:48 -05009
10namespace attn
11{
12
13/** @brief Logging level types */
14enum level
15{
16 INFO
17};
18
19/** @brief Logging event types */
20enum 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 */
30static const size_t trace_msg_max_len = 255;
31
32/** @brief create trace message */
33template <level L>
34void trace(const char* i_message);
35
36/** @brief commit checkstop event to log */
37void eventCheckstop(std::map<std::string, std::string>& i_errors);
38
39/** @brief commit special attention TI event to log */
Ben Tyner40717722020-09-23 09:43:20 -050040void eventTerminate(std::map<std::string, std::string> i_additionalData);
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050041
42/** @brief commit SBE vital event to log */
43void eventVital();
44
45/** @brief commit analyzer failure event to log */
46void eventHwDiagsFail(int i_error);
47
48/** @brief commit attention handler failure event to log */
49void eventAttentionFail(int i_error);
50
Ben Tynerff5f9a22020-11-19 19:54:12 -060051using FFDCTuple =
52 std::tuple<util::FFDCFormat, uint8_t, uint8_t, sdbusplus::message::unix_fd>;
53
Ben Tyner1b1915e2020-10-23 15:13:38 -050054/**
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 */
62util::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 */
73std::vector<util::FFDCFile> createFFDCFiles();
74
Ben Tynerff5f9a22020-11-19 19:54:12 -060075/**
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 */
84std::vector<FFDCTuple> createFFDCTuples(std::vector<util::FFDCFile>& files);
85
Ben Tynerb1ebfcb2020-05-08 18:52:48 -050086} // namespace attn