Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gabime/spdlog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabi Melman <gmelman1@gmail.com>2018-05-22 09:08:10 +0300
committerGitHub <noreply@github.com>2018-05-22 09:08:10 +0300
commit2aa25109efc5fe20eea799c69d84a7e7feeda1e7 (patch)
tree788c9d1413b982620fac6ce5d4ef52cf4d589865
parentd6b700eaf2e58d41cd6c3b768ed68b028d0691ea (diff)
parentbd3f8a3b921fa766bca85fe004046da91bf8f3d4 (diff)
Merge pull request #706 from Puasonych/master
Added file header support for step_logger
-rw-r--r--include/spdlog/contrib/sinks/step_file_sink.h17
1 files 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
@@ -58,9 +58,22 @@ 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<class Mutex, class FileNameCalc = default_step_file_name_calculator>
+template<class Mutex, class FileNameCalc = default_step_file_name_calculator,
+ class RecordingStartActions = default_action_when_recording_starts>
class step_file_sink SPDLOG_FINAL : public base_sink<Mutex>
{
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);
}