Skip to content

Commit 2cb61c8

Browse files
rbxclaude
andcommitted
Fix FMT 12 compatibility by replacing fmt::localtime with std::localtime
- Replace deprecated fmt::localtime with std::localtime in timestamp formatting - Add required <ctime> include for std::localtime - Dereference std::localtime return pointer for proper fmt formatting - Fixes compatibility with FMT 12+ where fmt::localtime was removed 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 71aac11 commit 2cb61c8

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

logger/Logger.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#endif
1616

1717
#include <cstdio> // printf
18+
#include <ctime> // std::localtime
1819
#include <iostream>
1920
#include <iterator> // std::back_inserter
2021

@@ -171,11 +172,11 @@ Logger::Logger(Severity severity, Verbosity verbosity, std::string_view file, st
171172
break;
172173
case VSpec::Info::timestamp_us:
173174
FillTimeInfos();
174-
fmt::format_to(std::back_inserter(fBWPrefix), "[{:%H:%M:%S}.{:06}]", fmt::localtime(fInfos.timestamp), fInfos.us.count());
175+
fmt::format_to(std::back_inserter(fBWPrefix), "[{:%H:%M:%S}.{:06}]", *std::localtime(&fInfos.timestamp), fInfos.us.count());
175176
break;
176177
case VSpec::Info::timestamp_s:
177178
FillTimeInfos();
178-
fmt::format_to(std::back_inserter(fBWPrefix), "[{:%H:%M:%S}]", fmt::localtime(fInfos.timestamp));
179+
fmt::format_to(std::back_inserter(fBWPrefix), "[{:%H:%M:%S}]", *std::localtime(&fInfos.timestamp));
179180
break;
180181
case VSpec::Info::severity:
181182
fmt::format_to(std::back_inserter(fBWPrefix), "[{}]", fInfos.severity_name);
@@ -207,11 +208,11 @@ Logger::Logger(Severity severity, Verbosity verbosity, std::string_view file, st
207208
break;
208209
case VSpec::Info::timestamp_us:
209210
FillTimeInfos();
210-
fmt::format_to(std::back_inserter(fColorPrefix), "[{}{:%H:%M:%S}.{:06}{}]", startColor(Color::fgCyan), fmt::localtime(fInfos.timestamp), fInfos.us.count(), endColor());
211+
fmt::format_to(std::back_inserter(fColorPrefix), "[{}{:%H:%M:%S}.{:06}{}]", startColor(Color::fgCyan), *std::localtime(&fInfos.timestamp), fInfos.us.count(), endColor());
211212
break;
212213
case VSpec::Info::timestamp_s:
213214
FillTimeInfos();
214-
fmt::format_to(std::back_inserter(fColorPrefix), "[{}{:%H:%M:%S}{}]", startColor(Color::fgCyan), fmt::localtime(fInfos.timestamp), endColor());
215+
fmt::format_to(std::back_inserter(fColorPrefix), "[{}{:%H:%M:%S}{}]", startColor(Color::fgCyan), *std::localtime(&fInfos.timestamp), endColor());
215216
break;
216217
case VSpec::Info::severity:
217218
fmt::format_to(std::back_inserter(fColorPrefix), "[{}]", GetColoredSeverityString(fInfos.severity));

0 commit comments

Comments
 (0)