|
|
@ -26,6 +26,7 @@ limitations under the License. */
|
|
|
|
#include <thrust/system_error.h>
|
|
|
|
#include <thrust/system_error.h>
|
|
|
|
#endif // PADDLE_WITH_CUDA
|
|
|
|
#endif // PADDLE_WITH_CUDA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <memory>
|
|
|
|
#include <memory>
|
|
|
@ -82,6 +83,22 @@ struct EnforceNotMet : public std::exception {
|
|
|
|
const char* what() const noexcept override { return err_str_.c_str(); }
|
|
|
|
const char* what() const noexcept override { return err_str_.c_str(); }
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
const std::string output_file_name{"paddle_err_info"};
|
|
|
|
|
|
|
|
void saveErrorInformation(const std::string& err) {
|
|
|
|
|
|
|
|
std::stringstream ss;
|
|
|
|
|
|
|
|
ss << output_file_name;
|
|
|
|
|
|
|
|
std::time_t t = std::time(nullptr);
|
|
|
|
|
|
|
|
std::tm* tm = std::localtime(&t);
|
|
|
|
|
|
|
|
char mbstr[100];
|
|
|
|
|
|
|
|
std::strftime(mbstr, sizeof(mbstr), "%F-%H-%M-%S", tm);
|
|
|
|
|
|
|
|
ss << "_" << mbstr << ".log";
|
|
|
|
|
|
|
|
std::ofstream err_file(ss.str(), std::ofstream::out);
|
|
|
|
|
|
|
|
if (err_file.is_open()) {
|
|
|
|
|
|
|
|
err_file << err;
|
|
|
|
|
|
|
|
err_file.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <typename StrType>
|
|
|
|
template <typename StrType>
|
|
|
|
inline void Init(StrType what, const char* f, int l) {
|
|
|
|
inline void Init(StrType what, const char* f, int l) {
|
|
|
|
static constexpr int TRACE_STACK_LIMIT = 100;
|
|
|
|
static constexpr int TRACE_STACK_LIMIT = 100;
|
|
|
@ -112,6 +129,8 @@ struct EnforceNotMet : public std::exception {
|
|
|
|
sout << "Windows not support stack backtrace yet.";
|
|
|
|
sout << "Windows not support stack backtrace yet.";
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
err_str_ = sout.str();
|
|
|
|
err_str_ = sout.str();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveErrorInformation(err_str_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|