mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 10:31:34 +08:00
Some cleanup
This commit is contained in:
parent
d4ab3a0c69
commit
afea332bbd
@ -48,14 +48,15 @@ namespace sinks {
|
||||
class sink;
|
||||
}
|
||||
|
||||
using filename_t = std::filesystem::path;
|
||||
#ifdef _WIN32 // Add L prefix to string literals on Windows when dealing with filenames
|
||||
#ifdef _WIN32
|
||||
// In windows, add L prefix for filename literals (e.g. L"filename.txt")
|
||||
#define SPDLOG_FILENAME_T_INNER(s) L##s
|
||||
#define SPDLOG_FILENAME_T(s) SPDLOG_FILENAME_T_INNER(s)
|
||||
#else
|
||||
#define SPDLOG_FILENAME_T(s) s
|
||||
#endif
|
||||
|
||||
using filename_t = std::filesystem::path;
|
||||
using log_clock = std::chrono::system_clock;
|
||||
using sink_ptr = std::shared_ptr<sinks::sink>;
|
||||
using sinks_init_list = std::initializer_list<sink_ptr>;
|
||||
|
@ -30,10 +30,8 @@ struct daily_filename_calculator {
|
||||
filename_t basename, ext;
|
||||
std::tie(basename, ext) = details::file_helper::split_by_extension(filename);
|
||||
std::basic_ostringstream<filename_t::value_type> oss;
|
||||
auto sep = SPDLOG_FILENAME_T('-');
|
||||
oss << basename.native() << SPDLOG_FILENAME_T('_') << std::setfill(SPDLOG_FILENAME_T('0')) << std::setw(4)
|
||||
<< now_tm.tm_year + 1900 << sep
|
||||
<< std::setw(2) << now_tm.tm_mon + 1 << sep << std::setw(2) << now_tm.tm_mday << ext.native();
|
||||
oss << basename.native() << '_' << std::setfill(SPDLOG_FILENAME_T('0')) << std::setw(4) << now_tm.tm_year + 1900 << '-'
|
||||
<< std::setw(2) << now_tm.tm_mon + 1 << '-' << std::setw(2) << now_tm.tm_mday << ext.native();
|
||||
return oss.str();
|
||||
}
|
||||
};
|
||||
|
@ -29,10 +29,9 @@ struct hourly_filename_calculator {
|
||||
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);
|
||||
std::basic_ostringstream<filename_t::value_type> oss;
|
||||
auto sep = SPDLOG_FILENAME_T('-');
|
||||
oss << basename.native() << sep << std::setfill(SPDLOG_FILENAME_T('0')) << std::setw(4) << now_tm.tm_year + 1900 << sep
|
||||
<< std::setw(2) << now_tm.tm_mon + 1 << sep << std::setw(2) << now_tm.tm_mday << sep << std::setw(2) << now_tm.tm_hour
|
||||
std::basic_ostringstream<filename_t::value_type> oss;
|
||||
oss << basename.native() << '-' << std::setfill(SPDLOG_FILENAME_T('0')) << std::setw(4) << now_tm.tm_year + 1900 << '-'
|
||||
<< std::setw(2) << now_tm.tm_mon + 1 << '-' << std::setw(2) << now_tm.tm_mday << '-' << std::setw(2) << now_tm.tm_hour
|
||||
<< ext.native();
|
||||
return oss.str();
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ filename_t rotating_file_sink<Mutex>::calc_filename(const filename_t &filename,
|
||||
filename_t ext;
|
||||
std::tie(basename, ext) = details::file_helper::split_by_extension(filename);
|
||||
std::basic_ostringstream<filename_t::value_type> oss;
|
||||
oss << basename.native() << "." << index << ext.native();
|
||||
oss << basename.native() << '.' << index << ext.native();
|
||||
return oss.str();
|
||||
//return fmt_lib::format(SPDLOG_FMT_STRING(SPDLOG_FILENAME_T("{}.{}{}")), basename, index, ext);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user