WIP. Logger for every modules

This commit is contained in:
emeric
2014-08-27 21:25:02 +02:00
parent 6afc4ac291
commit 07624995e7
42 changed files with 292 additions and 223 deletions
+6 -3
View File
@@ -1,5 +1,7 @@
#include <boost/thread.hpp>
#include "logger/Logger.hpp"
#include "DatabaseUpdateService.hpp"
namespace Service {
@@ -13,21 +15,22 @@ DatabaseUpdateService::DatabaseUpdateService(const Config& config)
void
DatabaseUpdateService::start(void)
{
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "DatabaseUpdateService, starting...";
_databaseUpdater.start();
}
void
DatabaseUpdateService::stop(void)
{
std::cout << "DatabaseUpdateService::stop, processing..." << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "DatabaseUpdateService, stopping...";
_databaseUpdater.stop();
std::cout << "DatabaseUpdateService::stop, process done" << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "DatabaseUpdateService, stopped";
}
void
DatabaseUpdateService::restart(void)
{
std::cout << "DatabaseUpdateService::restart" << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "DatabaseUpdateService, restart";
stop();
start();
}
+6 -5
View File
@@ -1,3 +1,4 @@
#include "logger/Logger.hpp"
#include "RemoteServerService.hpp"
@@ -15,24 +16,24 @@ RemoteServerService::RemoteServerService(const Config& config)
void
RemoteServerService::start(void)
{
std::cout << "RemoteServerService::start, starting..." << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::start, starting...";
_server.start();
std::cout << "RemoteServerService::start, started!" << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::start, started!";
}
void
RemoteServerService::stop(void)
{
std::cout << "RemoteServerService::stop, stopping..." << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::stop, stopping...";
_server.stop();
std::cout << "RemoteServerService::stop, stopped!" << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::stop, stopped!";
}
void
RemoteServerService::restart(void)
{
std::cout << "RemoteServerService::restart, not implemented!" << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::restart, not implemented!";
}
} // namespace Service
+7 -8
View File
@@ -1,3 +1,4 @@
#include "logger/Logger.hpp"
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
@@ -40,20 +41,20 @@ ServiceManager::run()
asyncWaitSignals();
std::cout << "ServiceManager::run Waiting for events..." << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "ServiceManager: waiting for events...";
try {
// Wait for events
_ioService.run();
}
catch( std::exception& e )
{
std::cerr << "Caugh exception in service : " << e.what() << std::endl;
LMS_LOG(MOD_SERVICE, SEV_ERROR) << "ServiceManager: exception in ioService::run: " << e.what();
}
// Stopping services
stopServices();
std::cout << "ServiceManager::run complete!" << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "ServiceManager: run complete !";
}
void
@@ -68,10 +69,8 @@ ServiceManager::asyncWaitSignals(void)
void
ServiceManager::startService(Service::pointer service)
{
std::cout << "ServiceManager::startService" << std::endl;
_services.insert(service);
service->start();
std::cout << "ServiceManager::startService done" << std::endl;
}
void
@@ -99,20 +98,20 @@ ServiceManager::restartServices(void)
void
ServiceManager::handleSignal(boost::system::error_code /*ec*/, int signo)
{
std::cout << "Received signal " << signo << std::endl;
LMS_LOG(MOD_SERVICE, SEV_INFO) << "Received signal " << signo;
switch (signo)
{
case SIGINT:
case SIGTERM:
case SIGQUIT:
std::cout << "Stopping services..." << std::endl;
LMS_LOG(MOD_SERVICE, SEV_NOTICE) << "Stopping services...";
stopServices();
// Do not listen for signals, this will make the ioservice.run return
break;
case SIGHUP:
std::cout << "Restarting services..." << std::endl;
LMS_LOG(MOD_SERVICE, SEV_NOTICE) << "Restarting services...";
restartServices();
asyncWaitSignals();
+5 -5
View File
@@ -1,4 +1,4 @@
#include <iostream>
#include "logger/Logger.hpp"
#include "UserInterfaceService.hpp"
#include "ui/LmsApplication.hpp"
@@ -30,7 +30,7 @@ UserInterfaceService::UserInterfaceService( boost::filesystem::path runAppPath,
for(int i = 0; i < argc; ++i)
{
std::cout << "i = " << i << ", arg = '" << argv[i] << "'" << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "i = " << i << ", arg = '" << argv[i] << "'";
}
_server.setServerConfiguration (argc, const_cast<char**>(argv));
@@ -44,15 +44,15 @@ void
UserInterfaceService::start(void)
{
_server.start();
std::cout << "UserInterfaceService::start -> Service started..." << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "UserInterfaceService::start -> Service started...";
}
void
UserInterfaceService::stop(void)
{
std::cout << "UserInterfaceService::stop -> stopping..." << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "UserInterfaceService::stop -> stopping...";
_server.stop();
std::cout << "UserInterfaceService::stop -> stopped!" << std::endl;
LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "UserInterfaceService::stop -> stopped!";
}
void