19#ifndef _BACKENDS_TOFINO_BF_P4C_LOGGING_EVENT_LOGGER_H_
20#define _BACKENDS_TOFINO_BF_P4C_LOGGING_EVENT_LOGGER_H_
28#include "lib/error_message.h"
42typedef std::function<void(
const char *,
unsigned,
const char *,
const IR::Node *)>
DebugHook;
58 const time_t BEGIN_TIME = std::time(
nullptr);
61 bool initialized =
false;
64 std::string lastManager =
"";
65 std::string lastPass =
"";
71 std::map<std::string, int> managerNameToIds;
72 std::vector<std::string> managerNames;
77 std::map<std::string, int> fileNameToIds;
78 std::vector<std::string> fileNames;
120 virtual std::ostream &
getDebugStream(
unsigned level,
const std::string &file)
const;
127 template <
typename T>
139 void passChange(
const std::string &manager,
const std::string &pass,
unsigned seq);
154 void init(
const std::string &outdir,
const std::string &filename);
191 void debug(
unsigned level,
const std::string &file,
const std::string &message);
196 void decision(
unsigned level,
const std::string &file,
const std::string &description,
197 const std::string &what,
const std::string &why);
214 return [](
const char *m,
unsigned s,
const char *p,
const IR::Node *) {
215 get().passChange(m, p, s);
221#define TAB2 TAB1 TAB1
222#define TAB3 TAB1 TAB2
223#define TAB4 TAB2 TAB2
224#define TAB5 TAB1 TAB4
225#define TAB6 TAB3 TAB3
226#define TAB7 TAB1 TAB6
236#define LOG_DEBUG(level, message) \
237 if (LOGGING(level)) { \
238 std::stringstream out; \
240 EventLogger::get().debug(level, __FILE__, out.str()); \
242#define LOG_DEBUG1(message) LOG_DEBUG(1, message)
243#define LOG_DEBUG2(message) LOG_DEBUG(2, message)
244#define LOG_DEBUG3(message) LOG_DEBUG(3, message)
245#define LOG_DEBUG4(message) LOG_DEBUG(4, message)
246#define LOG_DEBUG5(message) LOG_DEBUG(5, message)
247#define LOG_DEBUG6(message) LOG_DEBUG(6, message)
248#define LOG_DEBUG7(message) LOG_DEBUG(7, message)
249#define LOG_DEBUG8(message) LOG_DEBUG(8, message)
250#define LOG_DEBUG9(message) LOG_DEBUG(9, message)
256#define LOG_DECISION(level, description, chosen, why) \
257 EventLogger::get().decision(level, __FILE__, description, chosen, why);
258#define LOG_DECISION1(description, chosen, why) LOG_DECISION(1, description, chosen, why);
259#define LOG_DECISION2(description, chosen, why) LOG_DECISION(2, description, chosen, why);
260#define LOG_DECISION3(description, chosen, why) LOG_DECISION(3, description, chosen, why);
261#define LOG_DECISION4(description, chosen, why) LOG_DECISION(4, description, chosen, why);
262#define LOG_DECISION5(description, chosen, why) LOG_DECISION(5, description, chosen, why);
263#define LOG_DECISION6(description, chosen, why) LOG_DECISION(6, description, chosen, why);
264#define LOG_DECISION7(description, chosen, why) LOG_DECISION(7, description, chosen, why);
265#define LOG_DECISION8(description, chosen, why) LOG_DECISION(8, description, chosen, why);
266#define LOG_DECISION9(description, chosen, why) LOG_DECISION(9, description, chosen, why);
Definition event_logger.h:56
void decision(unsigned level, const std::string &file, const std::string &description, const std::string &what, const std::string &why)
Definition logging/event_logger.cpp:276
void logSink(const T *obj)
Definition logging/event_logger.cpp:135
void debug(unsigned level, const std::string &file, const std::string &message)
Definition logging/event_logger.cpp:265
void parserError(const P4::ParserErrorMessage &msg)
Definition logging/event_logger.cpp:233
int getManagerId(const std::string &name)
Definition logging/event_logger.cpp:117
void iterationChange(unsigned iteration, AllocPhase phase)
Definition logging/event_logger.cpp:291
void init(const std::string &outdir, const std::string &filename)
Definition logging/event_logger.cpp:151
int getFileNameId(const std::string &name)
Definition logging/event_logger.cpp:121
virtual std::ostream & getDebugStream(unsigned level, const std::string &file) const
Definition logging/event_logger.cpp:129
void pipeChange(int pipeId)
Definition logging/event_logger.cpp:300
void passChange(const std::string &manager, const std::string &pass, unsigned seq)
Definition logging/event_logger.cpp:218
void logProperties()
Definition logging/event_logger.cpp:182
void error(const P4::ErrorMessage &msg)
Definition logging/event_logger.cpp:243
void enable()
Definition event_logger.h:163
void deinit()
Definition logging/event_logger.cpp:194
void warning(const P4::ErrorMessage &msg)
Definition logging/event_logger.cpp:254
virtual int getTimeDifference() const
Definition logging/event_logger.cpp:125
static P4::DebugHook getDebugHook()
Definition event_logger.h:213
virtual std::string getStartTimestamp() const
Definition logging/event_logger.cpp:127
Definition table_placement.h:51
The namespace encapsulating IR node classes.
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
std::function< void(const char *manager, unsigned seqNo, const char *pass, const IR::Node *node)> DebugHook
Definition ir/pass_manager.h:38
Definition error_message.h:38
Definition error_message.h:70