2 Aesalon, a tool to visualize a program's behaviour at run-time.
3 Copyright (C) 2010, Aesalon Development Team.
5 Aesalon is distributed under the terms of the GNU GPLv3. For more
6 licensing information, see the file LICENSE included with the distribution.
8 @file monitor/src/vcommunication/LogSink.cpp
17 #include "vcommunication/LogSink.h"
19 #include "Coordinator.h"
20 #include "common/PathSanitizer.h"
23 namespace VCommunication
{
26 std::string filename
= Common::PathSanitizer::sanitize(Coordinator::instance()->vault()->get("logFile"));
28 std::cout
<< "LogSink: \"" << filename
<< "\"\n";
34 m_fd
= open(filename
.c_str(), O_RDWR
| O_TRUNC
| O_CREAT
, S_IRUSR
| S_IWUSR
);
36 sem_init(&m_logLock
, 0, 1);
42 sem_destroy(&m_logLock
);
47 void LogSink::sinkPacket(Common::VPacket
*packet
) {
48 if(m_fd
== -1) return;
52 ModuleID moduleID
= packet
->moduleID();
53 write(m_fd
, &moduleID
, sizeof(moduleID
));
55 pid_t processID
= packet
->processID();
56 write(m_fd
, &processID
, sizeof(processID
));
58 pthread_t threadID
= packet
->threadID();
59 write(m_fd
, &threadID
, sizeof(threadID
));
61 uint32_t dataSize
= packet
->dataSize();
62 write(m_fd
, &dataSize
, sizeof(dataSize
));
64 write(m_fd
, packet
->data(), dataSize
);
69 } // namespace VCommunication
70 } // namespace Monitor