MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Write

Method Write

Source/Engine/Core/Log.cpp:119–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119void Log::Logger::Write(const StringView& msg, LogType type)
120{
121 const auto ptr = msg.Get();
122 const auto length = msg.Length();
123 if (length <= 0)
124 return;
125 PROFILE_MEM(Engine);
126
127 LogLocker.Lock();
128 if (IsDuringLog)
129 {
130 LogLocker.Unlock();
131 return;
132 }
133 IsDuringLog = true;
134
135 // Send message to standard process output
136 if (CommandLine::Options.Std.IsTrue())
137 {
138#if PLATFORM_TEXT_IS_CHAR16
139 StringAnsi ansi(msg);
140 ansi += PLATFORM_LINE_TERMINATOR;
141 printf("%s", ansi.Get());
142#else
143 std::wcout.write(ptr, length);
144#if LOG_ENABLE_WINDOWS_SINGLE_NEW_LINE_CHAR
145 if (IsWindowsSingleNewLineChar)
146 std::wcout.write(TEXT("\n"), 1); // Github Actions show logs with duplicated new-line characters so skip \r
147 else
148#endif
149 std::wcout.write(TEXT(PLATFORM_LINE_TERMINATOR), ARRAY_COUNT(PLATFORM_LINE_TERMINATOR) - 1);
150#endif
151 }
152
153#if !BUILD_RELEASE
154 // Send message to platform logging
155 Platform::Log(msg, (int32)type);
156#endif
157
158#if LOG_ENABLE_FILE
159 // Write message to log file
160 constexpr int32 LogMaxWriteSize = 1 * 1024 * 1024; // 1GB
161 if (LogAfterInit && LogTotalWriteSize < LogMaxWriteSize)
162 {
163 LogTotalWriteSize += length;
164 LogFile->WriteBytes(ptr, length * sizeof(Char));
165 LogFile->WriteBytes(TEXT(PLATFORM_LINE_TERMINATOR), (ARRAY_COUNT(PLATFORM_LINE_TERMINATOR) - 1) * sizeof(Char));
166 if (LogTotalWriteSize >= LogMaxWriteSize)
167 {
168 StringView endMessage(TEXT("Trimming log file.\n\n"));
169 LogFile->WriteBytes(endMessage.Get(), endMessage.Length() * sizeof(Char));
170 }
171#if LOG_ENABLE_AUTO_FLUSH
172 LogFile->Flush();
173#endif
174 }
175#endif
176

Callers 15

SetupShadowsMethod · 0.45
WriteObjectsMethod · 0.45
SaveMethod · 0.45
BindDrawDataMethod · 0.45
SetIntMethod · 0.45
SetFloatMethod · 0.45
SetFloat2Method · 0.45
SetFloat3Method · 0.45
SetFloat4Method · 0.45
SetMethod · 0.45
SetIntFunction · 0.45
SetFloatFunction · 0.45

Calls 15

OnErrorFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
WriteFunction · 0.70
FlushFunction · 0.70
LogFunction · 0.50
StringViewClass · 0.50
GetMethod · 0.45
LengthMethod · 0.45
IsTrueMethod · 0.45
writeMethod · 0.45
WriteBytesMethod · 0.45

Tested by

no test coverage detected