mirror of
https://github.com/YosysHQ/yosys.git
synced 2026-10-06 10:03:36 +02:00
Add LogSink & LogMessage classes for a more robust sink solution.
Signed-off-by: Sean Luchen <[email protected]>
This commit is contained in:
committed by
Miodrag Milanovic
parent
2bcd69d12d
commit
8d6be2467b
+5
-10
@@ -39,7 +39,8 @@
|
||||
YOSYS_NAMESPACE_BEGIN
|
||||
|
||||
std::vector<FILE*> log_files;
|
||||
std::vector<std::ostream*> log_streams, log_warning_streams;
|
||||
std::vector<std::ostream*> log_streams;
|
||||
std::vector<LogSink*> log_sinks;
|
||||
std::vector<std::string> log_scratchpads;
|
||||
std::map<std::string, std::set<std::string>> log_hdump;
|
||||
std::vector<std::regex> log_warn_regexes, log_nowarn_regexes, log_werror_regexes;
|
||||
@@ -156,10 +157,6 @@ static void logv_string(std::string_view format, std::string str, LogSeverity se
|
||||
|
||||
for (auto f : log_streams)
|
||||
*f << time_str;
|
||||
|
||||
if (severity >= LogSeverity::LOG_WARNING)
|
||||
for (auto f : log_warning_streams)
|
||||
*f << time_str;
|
||||
}
|
||||
|
||||
for (auto f : log_files)
|
||||
@@ -168,11 +165,9 @@ static void logv_string(std::string_view format, std::string str, LogSeverity se
|
||||
for (auto f : log_streams)
|
||||
*f << str;
|
||||
|
||||
if (severity >= LogSeverity::LOG_WARNING)
|
||||
for (auto f : log_warning_streams) {
|
||||
*f << str;
|
||||
f->flush();
|
||||
}
|
||||
LogMessage log_msg(severity, str);
|
||||
for (LogSink* sink : log_sinks)
|
||||
sink->log(log_msg);
|
||||
|
||||
RTLIL::Design *design = yosys_get_design();
|
||||
if (design != nullptr)
|
||||
|
||||
+14
-1
@@ -91,9 +91,22 @@ enum LogSeverity {
|
||||
LOG_ERROR
|
||||
};
|
||||
|
||||
struct LogMessage {
|
||||
LogMessage(LogSeverity severity, std::string_view message) :
|
||||
severity(severity), timestamp(std::time(nullptr)), message(message) {}
|
||||
LogSeverity severity;
|
||||
std::time_t timestamp;
|
||||
std::string message;
|
||||
};
|
||||
|
||||
class LogSink {
|
||||
public:
|
||||
virtual void log(const LogMessage& message) = 0;
|
||||
};
|
||||
|
||||
extern std::vector<FILE*> log_files;
|
||||
extern std::vector<std::ostream*> log_streams;
|
||||
extern std::vector<std::ostream*> log_warning_streams;
|
||||
extern std::vector<LogSink*> log_sinks;
|
||||
extern std::vector<std::string> log_scratchpads;
|
||||
extern std::map<std::string, std::set<std::string>> log_hdump;
|
||||
extern std::vector<std::regex> log_warn_regexes, log_nowarn_regexes, log_werror_regexes;
|
||||
|
||||
Reference in New Issue
Block a user