mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 10:24:26 +01:00
door, logic: propagate new logfile to Door class
Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
parent
7e522e59af
commit
c058e1e4d0
@ -28,6 +28,7 @@
|
|||||||
#define DEFAULT_SERIAL_BAUDRATE 9600UL
|
#define DEFAULT_SERIAL_BAUDRATE 9600UL
|
||||||
|
|
||||||
#define LOG_FILENAME "doorlockd.log"
|
#define LOG_FILENAME "doorlockd.log"
|
||||||
|
#define LOG_SCRIPTS_FILENAME "doorlockd-scripts.log"
|
||||||
|
|
||||||
#define SHARED_LOCATION "@CMAKE_INSTALL_PREFIX@/share/doorlockd/"
|
#define SHARED_LOCATION "@CMAKE_INSTALL_PREFIX@/share/doorlockd/"
|
||||||
|
|
||||||
|
@ -166,6 +166,7 @@ int main(int argc, char** argv)
|
|||||||
std::string lockPagePrefix;
|
std::string lockPagePrefix;
|
||||||
fs::path logdir;
|
fs::path logdir;
|
||||||
std::string logfile;
|
std::string logfile;
|
||||||
|
std::string logfile_scripts;
|
||||||
unsigned int tokenLength;
|
unsigned int tokenLength;
|
||||||
std::string serDev;
|
std::string serDev;
|
||||||
unsigned int baudrate;
|
unsigned int baudrate;
|
||||||
@ -219,6 +220,7 @@ int main(int argc, char** argv)
|
|||||||
tokenTimeout = std::chrono::seconds(timeout);
|
tokenTimeout = std::chrono::seconds(timeout);
|
||||||
|
|
||||||
logfile = (logdir / LOG_FILENAME).string();
|
logfile = (logdir / LOG_FILENAME).string();
|
||||||
|
logfile_scripts = (logdir / LOG_SCRIPTS_FILENAME).string();
|
||||||
|
|
||||||
l.setLogFile(logfile);
|
l.setLogFile(logfile);
|
||||||
l.logFile(true);
|
l.logFile(true);
|
||||||
@ -250,6 +252,7 @@ int main(int argc, char** argv)
|
|||||||
tokenLength,
|
tokenLength,
|
||||||
serDev,
|
serDev,
|
||||||
baudrate,
|
baudrate,
|
||||||
|
logfile_scripts,
|
||||||
onClientMessage));
|
onClientMessage));
|
||||||
server(port);
|
server(port);
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
#include "../../doorcmds.h"
|
#include "../../doorcmds.h"
|
||||||
|
|
||||||
Door::Door(const std::string &serDev,
|
Door::Door(const std::string &serDev,
|
||||||
unsigned int baudrate) :
|
unsigned int baudrate,
|
||||||
|
const std::string &logfile_scripts) :
|
||||||
_baudrate(baudrate),
|
_baudrate(baudrate),
|
||||||
_port(_ioService, serDev),
|
_port(_ioService, serDev),
|
||||||
|
_logfile_scripts(logfile_scripts),
|
||||||
_logger(Logger::get())
|
_logger(Logger::get())
|
||||||
{
|
{
|
||||||
// Configure serial port
|
// Configure serial port
|
||||||
|
@ -20,10 +20,9 @@ public:
|
|||||||
using DoorCallback = std::function<void(Doormessage)>;
|
using DoorCallback = std::function<void(Doormessage)>;
|
||||||
enum class State {Unlocked, Locked};
|
enum class State {Unlocked, Locked};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Door(const std::string &serDev,
|
Door(const std::string &serDev,
|
||||||
unsigned int baudrate);
|
unsigned int baudrate,
|
||||||
|
const std::string &logfile_scripts);
|
||||||
~Door();
|
~Door();
|
||||||
|
|
||||||
State state() const;
|
State state() const;
|
||||||
@ -44,6 +43,8 @@ private:
|
|||||||
boost::asio::io_service _ioService = { };
|
boost::asio::io_service _ioService = { };
|
||||||
boost::asio::serial_port _port;
|
boost::asio::serial_port _port;
|
||||||
|
|
||||||
|
const std::string _logfile_scripts;
|
||||||
|
|
||||||
std::mutex _stateMutex = { };
|
std::mutex _stateMutex = { };
|
||||||
volatile State _state = { State::Locked };
|
volatile State _state = { State::Locked };
|
||||||
|
|
||||||
|
@ -12,9 +12,10 @@ Logic::Logic(const std::chrono::seconds tokenTimeout,
|
|||||||
const unsigned int tokenLength,
|
const unsigned int tokenLength,
|
||||||
const std::string &serDev,
|
const std::string &serDev,
|
||||||
const unsigned int baudrate,
|
const unsigned int baudrate,
|
||||||
|
const std::string &logfile_scripts,
|
||||||
std::condition_variable &onClientUpdate) :
|
std::condition_variable &onClientUpdate) :
|
||||||
_logger(Logger::get()),
|
_logger(Logger::get()),
|
||||||
_door(serDev, baudrate),
|
_door(serDev, baudrate, logfile_scripts),
|
||||||
_tokenTimeout(tokenTimeout),
|
_tokenTimeout(tokenTimeout),
|
||||||
_onClientUpdate(onClientUpdate),
|
_onClientUpdate(onClientUpdate),
|
||||||
_ldapUri(ldapUri),
|
_ldapUri(ldapUri),
|
||||||
|
@ -30,6 +30,7 @@ public:
|
|||||||
const unsigned int tokenLength,
|
const unsigned int tokenLength,
|
||||||
const std::string &serDev,
|
const std::string &serDev,
|
||||||
const unsigned int baudrate,
|
const unsigned int baudrate,
|
||||||
|
const std::string &logfile_scripts,
|
||||||
std::condition_variable &onClientUpdate);
|
std::condition_variable &onClientUpdate);
|
||||||
~Logic();
|
~Logic();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user