diff --git a/doorlockd/config.h.in b/doorlockd/config.h.in index b1437f4..296eb00 100644 --- a/doorlockd/config.h.in +++ b/doorlockd/config.h.in @@ -28,6 +28,7 @@ #define DEFAULT_SERIAL_BAUDRATE 9600UL #define LOG_FILENAME "doorlockd.log" +#define LOG_SCRIPTS_FILENAME "doorlockd-scripts.log" #define SHARED_LOCATION "@CMAKE_INSTALL_PREFIX@/share/doorlockd/" diff --git a/doorlockd/daemon/doorlockd.cpp b/doorlockd/daemon/doorlockd.cpp index b56b2d9..ad8e8f9 100644 --- a/doorlockd/daemon/doorlockd.cpp +++ b/doorlockd/daemon/doorlockd.cpp @@ -166,6 +166,7 @@ int main(int argc, char** argv) std::string lockPagePrefix; fs::path logdir; std::string logfile; + std::string logfile_scripts; unsigned int tokenLength; std::string serDev; unsigned int baudrate; @@ -219,6 +220,7 @@ int main(int argc, char** argv) tokenTimeout = std::chrono::seconds(timeout); logfile = (logdir / LOG_FILENAME).string(); + logfile_scripts = (logdir / LOG_SCRIPTS_FILENAME).string(); l.setLogFile(logfile); l.logFile(true); @@ -250,6 +252,7 @@ int main(int argc, char** argv) tokenLength, serDev, baudrate, + logfile_scripts, onClientMessage)); server(port); } diff --git a/doorlockd/lib/door.cpp b/doorlockd/lib/door.cpp index e773be7..46a5200 100644 --- a/doorlockd/lib/door.cpp +++ b/doorlockd/lib/door.cpp @@ -4,9 +4,11 @@ #include "../../doorcmds.h" Door::Door(const std::string &serDev, - unsigned int baudrate) : + unsigned int baudrate, + const std::string &logfile_scripts) : _baudrate(baudrate), _port(_ioService, serDev), + _logfile_scripts(logfile_scripts), _logger(Logger::get()) { // Configure serial port diff --git a/doorlockd/lib/door.h b/doorlockd/lib/door.h index 3b249f8..bb24b6f 100644 --- a/doorlockd/lib/door.h +++ b/doorlockd/lib/door.h @@ -20,10 +20,9 @@ public: using DoorCallback = std::function; enum class State {Unlocked, Locked}; - - Door(const std::string &serDev, - unsigned int baudrate); + unsigned int baudrate, + const std::string &logfile_scripts); ~Door(); State state() const; @@ -44,6 +43,8 @@ private: boost::asio::io_service _ioService = { }; boost::asio::serial_port _port; + const std::string _logfile_scripts; + std::mutex _stateMutex = { }; volatile State _state = { State::Locked }; diff --git a/doorlockd/lib/logic.cpp b/doorlockd/lib/logic.cpp index 6d019a8..645d1d4 100644 --- a/doorlockd/lib/logic.cpp +++ b/doorlockd/lib/logic.cpp @@ -12,9 +12,10 @@ Logic::Logic(const std::chrono::seconds tokenTimeout, const unsigned int tokenLength, const std::string &serDev, const unsigned int baudrate, + const std::string &logfile_scripts, std::condition_variable &onClientUpdate) : _logger(Logger::get()), - _door(serDev, baudrate), + _door(serDev, baudrate, logfile_scripts), _tokenTimeout(tokenTimeout), _onClientUpdate(onClientUpdate), _ldapUri(ldapUri), diff --git a/doorlockd/lib/logic.h b/doorlockd/lib/logic.h index 0b2fde6..8399136 100644 --- a/doorlockd/lib/logic.h +++ b/doorlockd/lib/logic.h @@ -30,6 +30,7 @@ public: const unsigned int tokenLength, const std::string &serDev, const unsigned int baudrate, + const std::string &logfile_scripts, std::condition_variable &onClientUpdate); ~Logic();