MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / LogPrintStr

Method LogPrintStr

src/logging.cpp:202–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202void BCLog::Logger::LogPrintStr(const std::string &str)
203{
204 std::string strTimestamped = LogTimestampStr(str);
205
206 if (m_print_to_console) {
207 // print to console
208 fwrite(strTimestamped.data(), 1, strTimestamped.size(), stdout);
209 fflush(stdout);
210 }
211 if (m_print_to_file) {
212 std::lock_guard<std::mutex> scoped_lock(m_file_mutex);
213
214 // buffer if we haven't opened the log yet
215 if (m_fileout == nullptr) {
216 m_msgs_before_open.push_back(strTimestamped);
217 }
218 else
219 {
220 // reopen the log file, if requested
221 if (m_reopen_file) {
222 m_reopen_file = false;
223 m_fileout = fsbridge::freopen(m_file_path, "a", m_fileout);
224 if (!m_fileout) {
225 return;
226 }
227 setbuf(m_fileout, nullptr); // unbuffered
228 }
229
230 FileWriteStr(strTimestamped, m_fileout);
231 }
232 }
233}
234
235void BCLog::Logger::ShrinkDebugFile()
236{

Callers 1

logging.hFile · 0.80

Calls 5

freopenFunction · 0.85
FileWriteStrFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected