mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-14 01:32:07 +08:00
Merge pull request #706 from Puasonych/master
Added file header support for step_logger
This commit is contained in:
commit
2aa25109ef
@ -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
|
* 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>
|
class step_file_sink SPDLOG_FINAL : public base_sink<Mutex>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -113,7 +126,7 @@ protected:
|
|||||||
std::tie(_current_filename, std::ignore) = FileNameCalc::calc_filename(_base_filename, _tmp_ext);
|
std::tie(_current_filename, std::ignore) = FileNameCalc::calc_filename(_base_filename, _tmp_ext);
|
||||||
_file_helper.open(_current_filename);
|
_file_helper.open(_current_filename);
|
||||||
_tp = _next_tp();
|
_tp = _next_tp();
|
||||||
_current_size = msg.formatted.size();
|
_current_size = msg.formatted.size() + RecordingStartActions::beginning_of_file();
|
||||||
}
|
}
|
||||||
_file_helper.write(msg);
|
_file_helper.write(msg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user