P4C
The P4 Compiler
|
#include <event_logger.h>
Public Types | |
enum class | AllocPhase { PhvAllocation , TablePlacement } |
Public Member Functions | |
void | debug (unsigned level, const std::string &file, const std::string &message) |
void | decision (unsigned level, const std::string &file, const std::string &description, const std::string &what, const std::string &why) |
void | deinit () |
void | enable () |
void | error (const P4::ErrorMessage &msg) |
void | init (const std::string &outdir, const std::string &filename) |
void | iterationChange (unsigned iteration, AllocPhase phase) |
void | parserError (const P4::ParserErrorMessage &msg) |
void | pipeChange (int pipeId) |
void | warning (const P4::ErrorMessage &msg) |
Static Public Member Functions | |
static EventLogger & | get () |
static P4::DebugHook | getDebugHook () |
Protected Member Functions | |
EventLogger (const EventLogger &other)=delete | |
EventLogger (EventLogger &&other)=delete | |
virtual std::ostream & | getDebugStream (unsigned level, const std::string &file) const |
int | getFileNameId (const std::string &name) |
int | getManagerId (const std::string &name) |
virtual std::string | getStartTimestamp () const |
virtual int | getTimeDifference () const |
void | logProperties () |
template<typename T > | |
void | logSink (const T *obj) |
void | nullInit () |
EventLogger & | operator= (const EventLogger &other)=delete |
void | passChange (const std::string &manager, const std::string &pass, unsigned seq) |
Custom logger for emitting EventLog for P4I Almost every message in the compiler should be logged via this interface. This class manages backward compatibility of logs.
void EventLogger::debug | ( | unsigned | level, |
const std::string & | file, | ||
const std::string & | message ) |
This function is expected to be called from LOG_DEBUGn macros
void EventLogger::decision | ( | unsigned | level, |
const std::string & | file, | ||
const std::string & | description, | ||
const std::string & | what, | ||
const std::string & | why ) |
This function is expected to be called from LOG_DECISIONn macros
void EventLogger::deinit | ( | ) |
Used in testing to manually reset spdlog at will
|
inline |
Enable logging to events into output file
Without this call, only properties and schema version are emitted. Logger should be initialized each time other jsons are emitted but should be enabled only if such option is set to TRUE.
void EventLogger::error | ( | const P4::ErrorMessage & | msg | ) |
This function is expected to be called from ErrorReporter as a custom sink for error messages
|
inlinestatic |
Get callback for logging changes in pass managers
|
protectedvirtual |
Gets output stream to which LOGn messages are normally emitted (backwards compatibility)
|
protected |
Returns index of name in fileNames array
If name is not in the array yet, it adds it to the end. Uses fileNameToIds to do the lookup in constant time.
|
protected |
Returns index of name in managerNames array
If name is not in the array yet, it adds it to the end. Uses managerNameToIds to do the lookup in constant time.
|
protectedvirtual |
Serializes BEGIN_TIME to string Placed into method because of testing
|
protectedvirtual |
Each message requires current timestamp in form of number of seconds since 1970-01-01 00:00
void EventLogger::init | ( | const std::string & | outdir, |
const std::string & | filename ) |
This function initializes the logger to emit messages to a file
outdir | Path to directory in which manifest.json is located |
filename | Path to logfile, relative to manifest.json |
void EventLogger::iterationChange | ( | unsigned | iteration, |
AllocPhase | phase ) |
This function should be called when new PhvAllocation or TablePlacement phase is started. Iteration number should be the same as in name of appropriate logfiles.
|
protected |
This function is called from constructor, bootstrapping event log with schema version so P4I can use correct parser
|
inlineprotected |
This is sink function for all logging functions. It accepts object to be serialized, serializes it to JSON and then calls underlying logger to dump it to output.
void EventLogger::parserError | ( | const P4::ParserErrorMessage & | msg | ) |
This function is expected to be called from ErrorReporter as a custom sink for parser error messages
|
protected |
This function is called through debug hooks from each pass manager
void EventLogger::pipeChange | ( | int | pipeId | ) |
This function should be called when backend is executed on a particular pipe
void EventLogger::warning | ( | const P4::ErrorMessage & | msg | ) |
This function is expected to be called from ErrorReporter as a custom sink for warning messages