Add Application Start/Stop Logging
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "MailServer/Server.h"
|
||||
#include <Logging.h>
|
||||
#include <asio.hpp>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
@@ -10,6 +11,9 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
Logging::OpenLog();
|
||||
Logging::SetLogMask(Logging::Severity::Debug);
|
||||
|
||||
/* error checking elided for brevity */
|
||||
int fd = ::open("/dev/null", O_WRONLY);
|
||||
::dup2(fd, 2);
|
||||
@@ -36,14 +40,28 @@ int main(int argc, char* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
Logging::Log(Logging::Severity::Info, "Starting AlarmServer");
|
||||
|
||||
asio::io_service io_service;
|
||||
|
||||
MailServer::Server s(io_service, port, path, url);
|
||||
|
||||
io_service.run();
|
||||
|
||||
Logging::Log(Logging::Severity::Info, "Stopping AlarmServer...");
|
||||
|
||||
Logging::CloseLog();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Exception: " << e.what() << std::endl;
|
||||
std::stringstream ss;
|
||||
ss << "ERROR: " << e.what() << std::endl;
|
||||
|
||||
std::cerr << ss.str() << std::endl;
|
||||
Logging::Log(Logging::Severity::Error, ss.str());
|
||||
|
||||
Logging::CloseLog();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user