Doorlockd: Replace logfile by logdir

In future, we might have several different logfiles.

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
This commit is contained in:
Ralf Ramsauer 2016-07-20 19:47:42 +02:00
parent 3721259f3e
commit f713ef6124
3 changed files with 11 additions and 4 deletions

View File

@ -59,7 +59,7 @@ set(CMAKE_CXX_FLAGS "-O2 -Wall -pedantic -Wextra -Weffc++ -Wno-unused-result")
set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb -Wall -pedantic -Wextra -Wno-unused-result")
set(CMAKE_C_FLAGS "-O2 -Wall -pedantic -Wextra -Wno-unused-result")
find_package(Boost 1.55.0 COMPONENTS program_options system REQUIRED)
find_package(Boost 1.55.0 COMPONENTS filesystem program_options system REQUIRED)
set(JSON_INCLUDE_DIR "/usr/include/jsoncpp" CACHE PATH "path to jsoncpp includes")

View File

@ -23,10 +23,12 @@
#define DEFAULT_LDAP_URI "ldaps://ldap1.binary.kitchen/ ldaps://ldap2.binary.kitchen/ ldaps://ldapm.binary.kitchen/"
#define DEFAULT_BINDDN "cn=%s,ou=people,dc=binary-kitchen,dc=de"
#define DEFAULT_TOKEN_LENGTH 6
#define DEFAULT_LOG_FILE "/var/log/doorlockd.log"
#define DEFAULT_LOG_DIR "/var/log/"
#define DEFAULT_SERIAL_DEVICE "/dev/ttyAMA0"
#define DEFAULT_SERIAL_BAUDRATE 9600UL
#define LOG_FILENAME "doorlockd.log"
#define SHARED_LOCATION "@CMAKE_INSTALL_PREFIX@/share/doorlockd/"
#define IMAGE_LOCATION SHARED_LOCATION "images/"

View File

@ -1,6 +1,7 @@
#include <csignal>
#include <iostream>
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#include <boost/asio.hpp>
@ -12,6 +13,7 @@
namespace po = boost::program_options;
namespace ba = boost::asio;
namespace fs = boost::filesystem;
using ba::ip::tcp;
// Info about doorlockd version
@ -162,6 +164,7 @@ int main(int argc, char** argv)
std::string ldapUri;
std::string bindDN;
std::string lockPagePrefix;
fs::path logdir;
std::string logfile;
unsigned int tokenLength;
std::string serDev;
@ -191,8 +194,8 @@ int main(int argc, char** argv)
("tokenLength,t",
po::value<unsigned int>(&tokenLength)->default_value(DEFAULT_TOKEN_LENGTH),
"Token length")
("logfile,l",
po::value<std::string>(&logfile)->default_value(DEFAULT_LOG_FILE),
("logdir,l",
po::value<fs::path>(&logdir)->default_value(DEFAULT_LOG_DIR),
"Log file")
("serial,i",
po::value<std::string>(&serDev)->default_value(DEFAULT_SERIAL_DEVICE),
@ -215,6 +218,8 @@ int main(int argc, char** argv)
tokenTimeout = std::chrono::seconds(timeout);
logfile = (logdir / LOG_FILENAME).string();
l.setLogFile(logfile);
l.logFile(true);
}