Struct hourly_filename_calculator

Synopsis

#include <include/spdlog/sinks/hourly_file_sink.h>

struct hourly_filename_calculator

Description

Generator of Hourly log file names in format basename.YYYY-MM-DD-HH.ext

Methods

calc_filenameCreate filename for the form basename.YYYY-MM-DD-H.

Source

Lines 27-37 in include/spdlog/sinks/hourly_file_sink.h.

struct hourly_filename_calculator
{
    // Create filename for the form basename.YYYY-MM-DD-H
    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_extension(filename);
        return fmt::format(
            SPDLOG_FILENAME_T("{}_{:04d}{:02d}{:02d}_{:02d}{}"), basename, now_tm.tm_year + 1900, now_tm.tm_mon + 1, now_tm.tm_mday, now_tm.tm_hour, ext);
    }
};





Add Discussion

Log in to comment