MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / print

Method print

src/Diagnostics/src/LogFile.cpp:20–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 }
19
20 void LogFile::print(Level level, std::string_view message)
21 {
22 if (!passesLevelFilter(level))
23 {
24 return;
25 }
26
27 if (!_file.is_open())
28 {
29 return;
30 }
31
32 std::string timestamp;
33 if (getWriteTimestamps())
34 {
35 auto now = std::chrono::system_clock::now();
36 timestamp = fmt::format("[{:%Y-%m-%d %H:%M:%S}] ", std::chrono::floor<std::chrono::seconds>(now));
37 }
38
39 const int intendSize = getIntendSize();
40
41 fmt::print(_file, "{}{}{:<{}}\n", timestamp, getLevelPrefix(level), message, intendSize);
42
43 // Ensure we are not loosing anything because of buffering in case of a crash.
44 _file.flush();
45 }
46}

Callers 1

printFunction · 0.45

Calls 3

passesLevelFilterFunction · 0.85
printFunction · 0.85
getLevelPrefixFunction · 0.85

Tested by

no test coverage detected