|
|
|
@ -19,27 +19,10 @@
|
|
|
|
|
namespace spdlog {
|
|
|
|
|
namespace sinks {
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Generator of daily log file names in format basename.YYYY-MM-DD.ext
|
|
|
|
|
*/
|
|
|
|
|
struct daily_filename_calculator
|
|
|
|
|
{
|
|
|
|
|
// Create filename for the form basename.YYYY-MM-DD
|
|
|
|
|
static filename_t calc_filename(const filename_t &filename, const tm &now_tm)
|
|
|
|
|
{
|
|
|
|
|
filename_t basename, ext;
|
|
|
|
|
std::tie(basename, ext) = details::file_helper::split_by_extenstion(filename);
|
|
|
|
|
std::conditional<std::is_same<filename_t::value_type, char>::value, fmt::memory_buffer, fmt::wmemory_buffer>::type w;
|
|
|
|
|
fmt::format_to(
|
|
|
|
|
w, SPDLOG_FILENAME_T("{}_{:04d}-{:02d}-{:02d}{}"), basename, now_tm.tm_year + 1900, now_tm.tm_mon + 1, now_tm.tm_mday, ext);
|
|
|
|
|
return fmt::to_string(w);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Rotating file sink based on date. rotates at midnight
|
|
|
|
|
*/
|
|
|
|
|
template<typename Mutex, typename FileNameCalc = daily_filename_calculator>
|
|
|
|
|
template<typename Mutex, typename FileNameCalc = details::filename_calculator>
|
|
|
|
|
class daily_file_sink final : public base_sink<Mutex>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|