LogBackend: include year in time stamp

Also use a numeric month instead of the month name.
This commit is contained in:
Max Kellermann
2025-03-13 08:59:55 +01:00
parent 84ff3c6a0d
commit 689d231809
2 changed files with 3 additions and 2 deletions

1
NEWS
View File

@@ -1,6 +1,7 @@
ver 0.24.1 (not yet released) ver 0.24.1 (not yet released)
* output * output
- sndio: fix rounding error in volume calculation - sndio: fix rounding error in volume calculation
* log: include year in time stamp
* fix build failure in the "id3tag" Meson subproject * fix build failure in the "id3tag" Meson subproject
ver 0.24 (2025/03/11) ver 0.24 (2025/03/11)

View File

@@ -81,10 +81,10 @@ EnableLogTimestamp() noexcept
static std::string_view static std::string_view
log_date() noexcept log_date() noexcept
{ {
static constexpr size_t LOG_DATE_BUF_SIZE = std::char_traits<char>::length("Jan 22 15:43:14 : ") + 1; static constexpr size_t LOG_DATE_BUF_SIZE = std::char_traits<char>::length("2025-01-22 15:43:14 : ") + 1;
static char buf[LOG_DATE_BUF_SIZE]; static char buf[LOG_DATE_BUF_SIZE];
time_t t = time(nullptr); time_t t = time(nullptr);
return FmtUnsafeSV(buf, "{:%b %d %T} : "sv, fmt::localtime(t)); return FmtUnsafeSV(buf, "{:%F %T} : "sv, fmt::localtime(t));
} }
#ifdef HAVE_SYSLOG #ifdef HAVE_SYSLOG