-
Notifications
You must be signed in to change notification settings - Fork 140
Added operation logging to JSON #1452
base: main
Are you sure you want to change the base?
Conversation
Now when you want to log operations to JSON file - you need to add flag -j or --json-dump and logs will be saved to your current directory to file "logs.json".
Codecov Report
@@ Coverage Diff @@
## main #1452 +/- ##
==========================================
- Coverage 99.78% 99.31% -0.47%
==========================================
Files 141 141
Lines 11654 11542 -112
==========================================
- Hits 11629 11463 -166
- Misses 25 79 +54
Continue to review full report at Codecov.
|
simulator/infra/log.cpp
Outdated
@@ -22,3 +22,7 @@ OStreamWrapper::~OStreamWrapper() | |||
{ | |||
ostream.rdbuf( buffer); | |||
} | |||
|
|||
|
|||
std::ofstream* visualizer_logger = new std::ofstream(".\\logs.json", std::ofstream::out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing, these variables should be non-static and reside in "Root" class. Objects can access them recursively.
Additionally, file name should be configurable from command line.
@@ -49,6 +50,9 @@ class Log | |||
mutable LogOstream sout; | |||
mutable LogOstream serr; | |||
|
|||
std::ofstream& jsonout(); | |||
bool jsonout_enabled = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using LogOstream
you may omit the boolean variable, and dump data unconditionally.
simulator/modules/core/perf_sim.cpp
Outdated
} | ||
|
||
template<typename ISA> | ||
void PerfSim<ISA>::stop_dump_json() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It must be called in destructor, so file closing and proper finalization would be guaranteed.
@andreyess I ran these changes locally and an output JSON file was not finalized. I made few comments how to improve code and resolve that issue, if you have time you may take a look. Unit tests would be very useful to guarantee stable behavior. |
Rebased from #1451
Now when you want to log operations to JSON file - you need to add flag -j or --json-dump and logs will be saved to your current directory to file "logs.json".