From d6b700eaf2e58d41cd6c3b768ed68b028d0691ea Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Mon, 21 May 2018 21:16:34 +0300 Subject: [PATCH 1/2] Update async_log_helper.h --- include/spdlog/details/async_log_helper.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/spdlog/details/async_log_helper.h b/include/spdlog/details/async_log_helper.h index a927d9f2..c3b76f02 100644 --- a/include/spdlog/details/async_log_helper.h +++ b/include/spdlog/details/async_log_helper.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include From bd3f8a3b921fa766bca85fe004046da91bf8f3d4 Mon Sep 17 00:00:00 2001 From: Puasonych Date: Tue, 22 May 2018 08:27:34 +0300 Subject: [PATCH 2/2] Added file header support --- include/spdlog/contrib/sinks/step_file_sink.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/include/spdlog/contrib/sinks/step_file_sink.h b/include/spdlog/contrib/sinks/step_file_sink.h index 7e90e0ad..395a534d 100644 --- a/include/spdlog/contrib/sinks/step_file_sink.h +++ b/include/spdlog/contrib/sinks/step_file_sink.h @@ -57,10 +57,23 @@ struct default_step_file_name_calculator } }; +/* + * The default action when recording starts + */ +struct default_action_when_recording_starts +{ + // Write the start message to the beginning of the file and return its size + static size_t beginning_of_file() + { + return 0; + } +}; + /* * Rotating file sink based on size and a specified time step */ -template +template class step_file_sink SPDLOG_FINAL : public base_sink { public: @@ -113,7 +126,7 @@ protected: std::tie(_current_filename, std::ignore) = FileNameCalc::calc_filename(_base_filename, _tmp_ext); _file_helper.open(_current_filename); _tp = _next_tp(); - _current_size = msg.formatted.size(); + _current_size = msg.formatted.size() + RecordingStartActions::beginning_of_file(); } _file_helper.write(msg); }