From e2ef1878ee6a61310f4f6847cbdd2260f60abda2 Mon Sep 17 00:00:00 2001 From: Jake Tuero Date: Wed, 22 Dec 2021 00:20:45 -0500 Subject: [PATCH] Default resume flag for truncating vs appending --- include/tensorboard_logger.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/tensorboard_logger.h b/include/tensorboard_logger.h index a82bc16..d691fa5 100644 --- a/include/tensorboard_logger.h +++ b/include/tensorboard_logger.h @@ -21,10 +21,12 @@ const std::string kTextPluginName = "text"; class TensorBoardLogger { public: - explicit TensorBoardLogger(const char *log_file) { + explicit TensorBoardLogger(const char *log_file, bool resume = false) { bucket_limits_ = nullptr; ofs_ = new std::ofstream( - log_file, std::ios::out | std::ios::trunc | std::ios::binary); + log_file, std::ios::out | + (resume ? std::ios::app : std::ios::trunc) | + std::ios::binary); if (!ofs_->is_open()) throw std::runtime_error("failed to open log_file " + std::string(log_file));