Open jslee02 opened 4 years ago
This is fairly advanced logic for a command line tool. Most CLI tools would not support this level of granularity.
Is the nature of this to check for certain printed output in the unit testing framework?
Is the nature of this to check for certain printed output in the unit testing framework?
Yes, that's the biggest motivation. It's currently not easy to unit-test for each warnings for even a simple case. I'm open to simpler way.
Chimera currently doesn't provide a way to redirect printing warnings to
std::cout
orstd::cerr
. This is less convenient to catch the warnings in unit testing.Possible solutions (from simple to sophisticated):
std::cout
andstd::cerr
. The we can pass a custom output stream that is designed for debugging. The custom output stream would simply collect the warnings in a list so it would have to parse the raw string.// emitting warning using default logger chimera::log::warnning(chimera::ErrorCode::B012, "Skipped function <...> because ..."); // or chimera::log::log(chimera::log::Level::WARNING, chimera::ErrorCode::B012, "Skipped function <...> because ...");
// emitting error chimera::log::error(chimera::ErrorCode::B013, "Skipped method <...> because ...");
// emitting log using specific logger std_cout_logger->warn(chimera::ErrorCode::B012, "Skipped function <...> because ..."); std_cerr_logger->error(chimera::ErrorCode::B013, "Skipped method <...> because ...");
// debug logger class DebugLogger : public chimera::log::Logger { public: bool HasError() const; bool HasWarning() const;
bool HasErrorCode(chimera::log::ErrorCode) const; std::vector GetLogsWithErrorCode(chimera::log::ErrorCode) const;
}