1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file src/monitor/LogOutput.cpp
14 #include "monitor/LogOutput.h"
15 #include "util/MessageSystem.h"
19 LogOutput::LogOutput(std::string spec
) {
20 m_fd
= open(spec
.c_str(), O_RDWR
| O_CREAT
, S_IWUSR
| S_IRUSR
);
22 Message(Fatal
, "Could not open log file \"" << spec
<< "\": " << std::strerror(errno
));
24 sem_init(&m_logSemaphore
, 0, 1);
27 LogOutput::~LogOutput() {
31 void LogOutput::output(Comm::Packet
*packet
) {
32 sem_wait(&m_logSemaphore
);
34 write(m_fd
, &packet
->header(), sizeof(packet
->header()));
35 write(m_fd
, packet
->data(), packet
->header().dataSize
);
37 sem_post(&m_logSemaphore
);
40 } // namespace Monitor