WIP. Added console/file logger

This commit is contained in:
emeric
2014-08-23 15:34:35 +02:00
parent d018922847
commit 5a66ff10af
6 changed files with 40 additions and 3 deletions
+2 -1
View File
@@ -28,6 +28,7 @@ lms_SOURCES = \
$(top_srcdir)/database/User.cpp \
$(top_srcdir)/database-updater/DatabaseUpdater.cpp \
$(top_srcdir)/database-updater/Checksum.cpp \
$(top_srcdir)/logger/Logger.cpp \
$(top_srcdir)/metadata/AvFormat.cpp \
$(top_srcdir)/metadata/Utils.cpp \
$(top_srcdir)/remote/messages/auth.pb.cc \
@@ -76,5 +77,5 @@ lms_SOURCES = \
$(top_srcdir)/ui/settings/SettingsUsers.cpp
lms_CXXFLAGS=-std=c++11 -Wall -I$(top_srcdir)/boost/ -I$(top_srcdir)/ui -I$(top_srcdir)/remote
lms_CXXFLAGS=-DBOOST_LOG_DYN_LINK -std=c++11 -Wall -I$(top_srcdir)/boost/ -I$(top_srcdir)/ui -I$(top_srcdir)/remote
+7
View File
@@ -5,6 +5,13 @@ ConfigReader::ConfigReader(boost::filesystem::path p)
_config.readFile(p.string().c_str());
}
void
ConfigReader::getLoggerConfig(Logger::Config& config)
{
config.enableFileLogging = _config.lookupValue("main.logger.file", config.logPath);
config.enableConsoleLogging = _config.lookup("main.logger.console");
}
void
ConfigReader::getUserInterfaceConfig(Service::UserInterfaceService::Config& config)
{
+6
View File
@@ -4,6 +4,8 @@
#include <boost/filesystem.hpp>
#include <libconfig.h++>
#include "logger/Logger.hpp"
#include "service/UserInterfaceService.hpp"
#include "service/RemoteServerService.hpp"
#include "service/DatabaseUpdateService.hpp"
@@ -14,6 +16,10 @@ class ConfigReader
ConfigReader(boost::filesystem::path p);
// Logger configuration
void getLoggerConfig(Logger::Config& config);
// Service configurations
void getUserInterfaceConfig(Service::UserInterfaceService::Config& config);
void getRemoteServerConfig(Service::RemoteServerService::Config& config);
void getDatabaseUpdateConfig(Service::DatabaseUpdateService::Config& config);
+10 -1
View File
@@ -87,6 +87,16 @@ AC_CHECK_LIB( [boost_iostreams],
,
[AC_MSG_ERROR([libboost_iostreams not found!])])
AC_CHECK_LIB( [boost_log],
[main],
,
[AC_MSG_ERROR([libboost_log not found!])])
AC_CHECK_LIB( [boost_log_setup],
[main],
,
[AC_MSG_ERROR([libboost_log_setup not found!])])
AC_CHECK_LIB( [protobuf],
[main],
,
@@ -114,7 +124,6 @@ AC_CHECK_LIB([wt],
[AC_MSG_ERROR([libwt not found!])])
AC_CONFIG_FILES([Makefile
test/Makefile])
+6 -1
View File
@@ -1,6 +1,11 @@
main = {
log-level = 1;
logger = {
file = "/var/lms/lms.log" # comment to disable file logging
console = true;
}
db = "/var/lms/lms.db";
}
+9
View File
@@ -1,5 +1,7 @@
#include <boost/filesystem.hpp>
#include "logger/Logger.hpp"
#include "config/ConfigReader.hpp"
#include "transcode/AvConvTranscoder.hpp"
#include "av/Common.hpp"
@@ -39,6 +41,13 @@ int main(int argc, char* argv[])
ConfigReader configReader(configFile);
// Initializa logging facility
{
Logger::Config loggerConfig;
configReader.getLoggerConfig(loggerConfig);
Logger::instance().init(loggerConfig);
}
Service::DatabaseUpdateService::Config dbUpdateConfig;
configReader.getDatabaseUpdateConfig(dbUpdateConfig);