forked from CobaltFusion/DebugViewPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileWriter.cpp
More file actions
38 lines (33 loc) · 1.08 KB
/
Copy pathFileWriter.cpp
File metadata and controls
38 lines (33 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// (C) Copyright Gert-Jan de Vos and Jan Wilmans 2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "DebugViewppLib/LogFile.h"
#include "DebugViewppLib/FileIO.h"
#include "DebugViewppLib/FileWriter.h"
namespace fusion {
namespace debugviewpp {
FileWriter::FileWriter(const std::wstring& filename, LogFile& logfile) :
m_logfile(logfile)
{
OpenLogFile(m_ofstream, filename, OpenMode::Append);
m_thread = std::thread(&FileWriter::Run, this);
}
void FileWriter::Run()
{
//todo: we need locking on Logfile, think of ClearLog()
int writeIndex = 0;
for (;;)
{
while (writeIndex < m_logfile.Count())
{
auto msg = m_logfile[writeIndex];
++writeIndex;
WriteLogFileMessage(m_ofstream, msg.time, msg.systemTime, msg.processId, msg.processName, msg.text);
}
m_ofstream.flush();
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
} // namespace debugviewpp
} // namespace fusion