You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chimera currently doesn't provide a way to redirect printing warnings to std::cout or std::cerr. This is less convenient to catch the warnings in unit testing.
Possible solutions (from simple to sophisticated):
Parameterize the target output stream so that we can set it other than std::cout and std::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.
Introduce logging mechanism like spdlog. This way we could use various logger (e.g., std::err logger, file logger, even a custom logger that collects the error instances). One additional advantage of this would be that we could encode error code in a log instance so we can more easily filtering, grouping, and lookup logs for unit testing. I'm thinking of APIs something like:
// before running the ClangToolchimera::log::set_default_logger(chimera::log::FileLogger("<path>"));
chimera::log::set_default_logger(chimera::log::StdCoutLogger());
chimera::log::set_default_logger(chimera::log::StdCerrLogger());
chimera::log::set_default_logger(chimera::log::DebugLogger());
// emitting warning using default loggerchimera::log::warnning(chimera::ErrorCode::B012, "Skipped function <...> because ..."); // orchimera::log::log(chimera::log::Level::WARNING, chimera::ErrorCode::B012, "Skipped function <...> because ...");
// emitting errorchimera::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 loggerclassDebugLogger : publicchimera::log::Logger {
public:boolHasError() const;
boolHasWarning() const;
boolHasErrorCode(chimera::log::ErrorCode) const;
std::vector<Log> GetLogsWithErrorCode(chimera::log::ErrorCode) const;
}
The text was updated successfully, but these errors were encountered:
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.The text was updated successfully, but these errors were encountered: