mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralgw.git
synced 2025-11-02 03:37:57 +00:00
Framework update
This commit is contained in:
@@ -46,9 +46,9 @@ namespace OpenWifi {
|
||||
Cmd.UUID,
|
||||
RPC_Id)) {
|
||||
StorageService()->SetCommandExecuted(Cmd.UUID);
|
||||
Logger_.information(Poco::format("Sent command '%s' to '%s'",Cmd.Command,Cmd.SerialNumber));
|
||||
Logger().information(Poco::format("Sent command '%s' to '%s'",Cmd.Command,Cmd.SerialNumber));
|
||||
} else {
|
||||
Logger_.information(Poco::format("Failed to send command '%s' to %s",Cmd.Command,Cmd.SerialNumber));
|
||||
Logger().information(Poco::format("Failed to send command '%s' to %s",Cmd.Command,Cmd.SerialNumber));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,34 +57,34 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
int CommandManager::Start() {
|
||||
Logger_.notice("Starting...");
|
||||
Logger().notice("Starting...");
|
||||
ManagerThread.start(*this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CommandManager::Stop() {
|
||||
Logger_.notice("Stopping...");
|
||||
Logger().notice("Stopping...");
|
||||
Running_ = false;
|
||||
ManagerThread.wakeUp();
|
||||
ManagerThread.join();
|
||||
}
|
||||
|
||||
void CommandManager::WakeUp() {
|
||||
Logger_.notice("Waking up..");
|
||||
Logger().notice("Waking up..");
|
||||
ManagerThread.wakeUp();
|
||||
}
|
||||
|
||||
void CommandManager::Janitor() {
|
||||
std::lock_guard G(Mutex_);
|
||||
uint64_t Now = time(nullptr);
|
||||
Logger_.information("Janitor starting.");
|
||||
Logger().information("Janitor starting.");
|
||||
for(auto i=OutStandingRequests_.begin();i!=OutStandingRequests_.end();) {
|
||||
if((Now-i->second.Submitted)>120)
|
||||
i = OutStandingRequests_.erase(i);
|
||||
else
|
||||
++i;
|
||||
}
|
||||
Logger_.information("Janitor finished.");
|
||||
Logger().information("Janitor finished.");
|
||||
}
|
||||
|
||||
bool CommandManager::GetCommand(uint64_t Id, const std::string &SerialNumber, CommandTag &T) {
|
||||
@@ -117,7 +117,7 @@ namespace OpenWifi {
|
||||
CompleteRPC.set(uCentralProtocol::METHOD, Method);
|
||||
CompleteRPC.set(uCentralProtocol::PARAMS, Params);
|
||||
Poco::JSON::Stringifier::stringify(CompleteRPC, ToSend);
|
||||
Logger_.information(
|
||||
Logger().information(
|
||||
Poco::format("(%s): Sending command '%s', ID: %lu", SerialNumber, Method, Id));
|
||||
CommandTagIndex Idx{.Id = Id, .SerialNumber = SerialNumber};
|
||||
CommandTag Tag;
|
||||
@@ -133,25 +133,25 @@ namespace OpenWifi {
|
||||
void CommandManager::PostCommandResult(const std::string &SerialNumber, Poco::JSON::Object::Ptr Obj) {
|
||||
|
||||
if(!Obj->has(uCentralProtocol::ID)){
|
||||
Logger_.error(Poco::format("(%s): Invalid RPC response.",SerialNumber));
|
||||
Logger().error(Poco::format("(%s): Invalid RPC response.",SerialNumber));
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t ID = Obj->get(uCentralProtocol::ID);
|
||||
if(ID<2) {
|
||||
Logger_.error(Poco::format("(%s): Ignoring RPC response.",SerialNumber));
|
||||
Logger().error(Poco::format("(%s): Ignoring RPC response.",SerialNumber));
|
||||
return;
|
||||
}
|
||||
std::unique_lock G(Mutex_);
|
||||
auto Idx = CommandTagIndex{.Id = ID, .SerialNumber = SerialNumber};
|
||||
auto RPC = OutStandingRequests_.find(Idx);
|
||||
if (RPC == OutStandingRequests_.end()) {
|
||||
Logger_.warning(Poco::format("(%s): Outdated RPC %lu", SerialNumber, ID));
|
||||
Logger().warning(Poco::format("(%s): Outdated RPC %lu", SerialNumber, ID));
|
||||
return;
|
||||
}
|
||||
RPC->second.Completed = std::time(nullptr);
|
||||
RPC->second.Result = Obj;
|
||||
Logger_.information(Poco::format("(%s): Received RPC answer %lu", SerialNumber, ID));
|
||||
Logger().information(Poco::format("(%s): Received RPC answer %lu", SerialNumber, ID));
|
||||
G.unlock();
|
||||
StorageService()->CommandCompleted(RPC->second.UUID, Obj, true);
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace OpenWifi {
|
||||
|
||||
int DeviceRegistry::Start() {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
Logger_.notice("Starting ");
|
||||
Logger().notice("Starting ");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DeviceRegistry::Stop() {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
Logger_.notice("Stopping ");
|
||||
Logger().notice("Stopping ");
|
||||
}
|
||||
|
||||
bool DeviceRegistry::GetStatistics(const std::string &SerialNumber, std::string & Statistics) {
|
||||
@@ -132,7 +132,7 @@ namespace OpenWifi {
|
||||
try {
|
||||
return Device->second->WSConn_->Send(Payload);
|
||||
} catch (...) {
|
||||
Logger_.debug(Poco::format("Could not send data to device '%s'", SerialNumber));
|
||||
Logger().debug(Poco::format("Could not send data to device '%s'", SerialNumber));
|
||||
Device->second->Conn_.Address = "";
|
||||
Device->second->WSConn_ = nullptr;
|
||||
Device->second->Conn_.Connected = false;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenWifi {
|
||||
static const std::string URI_BASE{"/v1/upload/"};
|
||||
|
||||
int FileUploader::Start() {
|
||||
Logger_.notice("Starting.");
|
||||
Logger().notice("Starting.");
|
||||
|
||||
Poco::File UploadsDir(MicroService::instance().ConfigPath("openwifi.fileuploader.path","/tmp"));
|
||||
Path_ = UploadsDir.path();
|
||||
@@ -37,7 +37,7 @@ namespace OpenWifi {
|
||||
try {
|
||||
UploadsDir.createDirectory();
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
Path_ = "/tmp";
|
||||
}
|
||||
}
|
||||
@@ -46,13 +46,13 @@ namespace OpenWifi {
|
||||
Svr.Address() + ":" + std::to_string(Svr.Port()) +
|
||||
" key:" + Svr.KeyFile() +
|
||||
" cert:" + Svr.CertFile()};
|
||||
Logger_.information(l);
|
||||
Logger().information(l);
|
||||
|
||||
auto Sock{Svr.CreateSecureSocket(Logger_)};
|
||||
auto Sock{Svr.CreateSecureSocket(Logger())};
|
||||
|
||||
Svr.LogCert(Logger_);
|
||||
Svr.LogCert(Logger());
|
||||
if(!Svr.RootCA().empty())
|
||||
Svr.LogCas(Logger_);
|
||||
Svr.LogCas(Logger());
|
||||
|
||||
auto Params = new Poco::Net::HTTPServerParams;
|
||||
Params->setMaxThreads(16);
|
||||
@@ -66,10 +66,10 @@ namespace OpenWifi {
|
||||
} else {
|
||||
FullName_ = TmpName + URI_BASE ;
|
||||
}
|
||||
Logger_.information(Poco::format("Uploader URI base is '%s'", FullName_));
|
||||
Logger().information(Poco::format("Uploader URI base is '%s'", FullName_));
|
||||
}
|
||||
|
||||
auto NewServer = std::make_unique<Poco::Net::HTTPServer>(new FileUpLoaderRequestHandlerFactory(Logger_), Pool_, Sock, Params);
|
||||
auto NewServer = std::make_unique<Poco::Net::HTTPServer>(new FileUpLoaderRequestHandlerFactory(Logger()), Pool_, Sock, Params);
|
||||
NewServer->start();
|
||||
Servers_.push_back(std::move(NewServer));
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace OpenWifi {
|
||||
|
||||
void FileUploader::reinitialize(Poco::Util::Application &self) {
|
||||
MicroService::instance().LoadConfigurationFile();
|
||||
Logger_.information("Reinitializing.");
|
||||
Logger().information("Reinitializing.");
|
||||
Stop();
|
||||
Start();
|
||||
}
|
||||
@@ -144,7 +144,7 @@ namespace OpenWifi {
|
||||
|
||||
std::string FinalFileName = FileUploader()->Path() + "/" + UUID_;
|
||||
|
||||
Logger_.information(Poco::format("FILE-UPLOADER: uploading trace for %s", FinalFileName));
|
||||
Logger().information(Poco::format("FILE-UPLOADER: uploading trace for %s", FinalFileName));
|
||||
Poco::CountingInputStream InputStream(Stream);
|
||||
std::ofstream OutputStream(FinalFileName, std::ofstream::out);
|
||||
Poco::StreamCopier::copyStream(InputStream, OutputStream);
|
||||
@@ -159,7 +159,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return;
|
||||
} catch (const Poco::Exception &E ) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
Error_ = std::string("Upload caused an internal error: ") + E.what() ;
|
||||
}
|
||||
}
|
||||
@@ -168,6 +168,7 @@ namespace OpenWifi {
|
||||
[[nodiscard]] const std::string& Name() const { return Name_; }
|
||||
[[nodiscard]] bool Good() const { return Good_; }
|
||||
std::string & Error() { return Error_; }
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
|
||||
private:
|
||||
uint64_t Length_=0;
|
||||
@@ -191,7 +192,7 @@ namespace OpenWifi {
|
||||
void handleRequest(Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override
|
||||
{
|
||||
try {
|
||||
FileUploaderPartHandler partHandler(UUID_,Logger_);
|
||||
FileUploaderPartHandler partHandler(UUID_,Logger());
|
||||
|
||||
Poco::Net::HTMLForm form(Request, Request.stream(), partHandler);
|
||||
|
||||
@@ -215,12 +216,13 @@ namespace OpenWifi {
|
||||
}
|
||||
catch( const Poco::Exception & E )
|
||||
{
|
||||
Logger_.warning(Poco::format("Error occurred while performing upload. Error='%s'",E.displayText()));
|
||||
Logger().warning(Poco::format("Error occurred while performing upload. Error='%s'",E.displayText()));
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
}
|
||||
}
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
private:
|
||||
std::string UUID_;
|
||||
Poco::Logger & Logger_;
|
||||
@@ -228,7 +230,7 @@ namespace OpenWifi {
|
||||
|
||||
Poco::Net::HTTPRequestHandler *FileUpLoaderRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & Request) {
|
||||
|
||||
Logger_.debug(Poco::format("REQUEST(%s): %s %s", Utils::FormatIPv6(Request.clientAddress().toString()), Request.getMethod(), Request.getURI()));
|
||||
Logger().debug(Poco::format("REQUEST(%s): %s %s", Utils::FormatIPv6(Request.clientAddress().toString()), Request.getMethod(), Request.getURI()));
|
||||
|
||||
// The UUID should be after the /v1/upload/ part...
|
||||
auto UUIDLocation = Request.getURI().find_first_of(URI_BASE);
|
||||
@@ -240,18 +242,18 @@ namespace OpenWifi {
|
||||
{
|
||||
// make sure we do not allow anyone else to overwrite our file
|
||||
FileUploader()->RemoveRequest(UUID);
|
||||
return new FormRequestHandler(UUID,Logger_);
|
||||
return new FormRequestHandler(UUID,Logger());
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger_.warning(Poco::format("Unknown UUID=%s",UUID));
|
||||
Logger().warning(Poco::format("Unknown UUID=%s",UUID));
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void FileUploader::Stop() {
|
||||
Logger_.notice("Stopping ");
|
||||
Logger().notice("Stopping ");
|
||||
for( const auto & svr : Servers_ )
|
||||
svr->stop();
|
||||
Servers_.clear();
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace OpenWifi {
|
||||
Logger_(L){}
|
||||
|
||||
Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &request) override;
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
private:
|
||||
Poco::Logger & Logger_;
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenWifi {
|
||||
|
||||
void OUIServer::reinitialize(Poco::Util::Application &self) {
|
||||
MicroService::instance().LoadConfigurationFile();
|
||||
Logger_.information("Reinitializing.");
|
||||
Logger().information("Reinitializing.");
|
||||
Stop();
|
||||
Start();
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace OpenWifi {
|
||||
OS.close();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return true;
|
||||
} catch ( const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ namespace OpenWifi {
|
||||
F1.remove();
|
||||
Poco::File F2(LatestOUIFileName);
|
||||
F2.renameTo(CurrentOUIFileName);
|
||||
Logger_.information(Poco::format("New OUI file %s downloaded.",LatestOUIFileName));
|
||||
Logger().information(Poco::format("New OUI file %s downloaded.",LatestOUIFileName));
|
||||
} else if(OUIs_.empty()) {
|
||||
if(ProcessFile(CurrentOUIFileName, TmpOUIs)) {
|
||||
LastUpdate_ = time(nullptr);
|
||||
|
||||
@@ -46,10 +46,10 @@ namespace OpenWifi {
|
||||
Save();
|
||||
return true;
|
||||
} else {
|
||||
Logger_.information(Poco::format("DEVICE(%s): State is missing interfaces",SerialNumber_));
|
||||
Logger().information(Poco::format("DEVICE(%s): State is missing interfaces",SerialNumber_));
|
||||
}
|
||||
} catch (const Poco::Exception &E ) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ namespace OpenWifi {
|
||||
const auto & Result = ParsedMessage.extract<Poco::JSON::Object::Ptr>();
|
||||
return Add(Result);
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenWifi {
|
||||
bool Initialize(std::string & SerialNumber);
|
||||
bool Save();
|
||||
static bool GetAssociations(const Poco::JSON::Object::Ptr &Ptr, uint64_t &Radios_2G, uint64_t &Radios_5G);
|
||||
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
private:
|
||||
std::string SerialNumber_;
|
||||
Poco::JSON::Object State_;
|
||||
|
||||
@@ -14,23 +14,23 @@ namespace OpenWifi {
|
||||
auto Now = std::time(nullptr);
|
||||
for(const auto &i:DBs_) {
|
||||
if (!Poco::icompare(i.DBName, "healthchecks")) {
|
||||
Logger_.information("Archiving HealthChecks...");
|
||||
Logger().information("Archiving HealthChecks...");
|
||||
StorageService()->RemoveHealthChecksRecordsOlderThan(
|
||||
Now - (i.HowManyDays * 24 * 60 * 60));
|
||||
} else if (!Poco::icompare(i.DBName, "statistics")) {
|
||||
Logger_.information("Archiving Statistics...");
|
||||
Logger().information("Archiving Statistics...");
|
||||
StorageService()->RemoveStatisticsRecordsOlderThan(
|
||||
Now - (i.HowManyDays * 24 * 60 * 60));
|
||||
} else if (!Poco::icompare(i.DBName, "devicelogs")) {
|
||||
Logger_.information("Archiving Device Logs...");
|
||||
Logger().information("Archiving Device Logs...");
|
||||
StorageService()->RemoveDeviceLogsRecordsOlderThan(
|
||||
Now - (i.HowManyDays * 24 * 60 * 60));
|
||||
} else if (!Poco::icompare(i.DBName, "commandlist")) {
|
||||
Logger_.information("Archiving Command History...");
|
||||
Logger().information("Archiving Command History...");
|
||||
StorageService()->RemoveCommandListRecordsOlderThan(
|
||||
Now - (i.HowManyDays * 24 * 60 * 60));
|
||||
} else {
|
||||
Logger_.information(Poco::format("Cannot archive DB '%s'", i.DBName));
|
||||
Logger().information(Poco::format("Cannot archive DB '%s'", i.DBName));
|
||||
}
|
||||
}
|
||||
AppServiceRegistry().Set("lastStorageArchiverRun", (uint64_t) Now);
|
||||
@@ -53,7 +53,7 @@ namespace OpenWifi {
|
||||
|
||||
Enabled_ = MicroService::instance().ConfigGetBool("archiver.enabled",false);
|
||||
if(!Enabled_) {
|
||||
Logger_.information("Archiver is disabled.");
|
||||
Logger().information("Archiver is disabled.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace OpenWifi {
|
||||
|
||||
int NextRun = CalculateDelta(RunAtHour_,RunAtMin_);
|
||||
|
||||
Logger_.information(Poco::format("Next run in %d seconds.",NextRun));
|
||||
Logger().information(Poco::format("Next run in %d seconds.",NextRun));
|
||||
|
||||
Timer_.setStartInterval( NextRun * 1000);
|
||||
Timer_.setPeriodicInterval(24 * 60 * 60 * 1000); // 1 hours
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace OpenWifi {
|
||||
inline void AddDb(const ArchiverDBEntry &E ) {
|
||||
DBs_.push_back(E);
|
||||
}
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
private:
|
||||
Poco::Logger &Logger_;
|
||||
ArchiverDBEntryVec DBs_;
|
||||
@@ -49,7 +50,7 @@ namespace OpenWifi {
|
||||
private:
|
||||
std::atomic_bool Enabled_ = false;
|
||||
Poco::Timer Timer_;
|
||||
Archiver Archiver_{Logger_};
|
||||
Archiver Archiver_{Logger()};
|
||||
std::unique_ptr<Poco::TimerCallback<Archiver>> ArchiverCallback_;
|
||||
|
||||
StorageArchiver() noexcept:
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenWifi {
|
||||
|
||||
void Storage::Stop() {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
Logger_.notice("Stopping.");
|
||||
Logger().notice("Stopping.");
|
||||
StorageClass::Stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void TelemetryStream::Stop() {
|
||||
Logger_.notice("Stopping reactors...");
|
||||
Logger().notice("Stopping reactors...");
|
||||
ReactorPool_.Stop();
|
||||
|
||||
if(Running_) {
|
||||
@@ -194,20 +194,20 @@ namespace OpenWifi {
|
||||
*WS_, Poco::NObserver<TelemetryClient, Poco::Net::ErrorNotification>(
|
||||
*this, &TelemetryClient::OnSocketError));
|
||||
Registered_ = true;
|
||||
Logger_.information(Poco::format("CONNECTION(%s): completed.", CId_));
|
||||
Logger().information(Poco::format("CONNECTION(%s): completed.", CId_));
|
||||
return;
|
||||
}
|
||||
} catch (const Poco::Net::SSLException &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
|
||||
TelemetryClient::~TelemetryClient() {
|
||||
Logger_.information("Closing telemetry session.");
|
||||
Logger().information("Closing telemetry session.");
|
||||
if(Registered_ && WS_)
|
||||
{
|
||||
Reactor_.removeEventHandler(*WS_,
|
||||
@@ -235,7 +235,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void TelemetryClient::SendTelemetryShutdown() {
|
||||
Logger_.information(Poco::format("TELEMETRY-SHUTDOWN(%s): Closing.",CId_));
|
||||
Logger().information(Poco::format("TELEMETRY-SHUTDOWN(%s): Closing.",CId_));
|
||||
TelemetryStream()->DeRegisterClient(UUID_);
|
||||
Poco::JSON::Object StopMessage;
|
||||
StopMessage.set("jsonrpc","2.0");
|
||||
@@ -255,13 +255,13 @@ namespace OpenWifi {
|
||||
|
||||
void TelemetryClient::OnSocketShutdown(const Poco::AutoPtr<Poco::Net::ShutdownNotification>& pNf) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
Logger_.information(Poco::format("SOCKET-SHUTDOWN(%s): Orderly shutdown.", CId_));
|
||||
Logger().information(Poco::format("SOCKET-SHUTDOWN(%s): Orderly shutdown.", CId_));
|
||||
SendTelemetryShutdown();
|
||||
}
|
||||
|
||||
void TelemetryClient::OnSocketError(const Poco::AutoPtr<Poco::Net::ErrorNotification>& pNf) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
Logger_.information(Poco::format("SOCKET-ERROR(%s): Closing.",CId_));
|
||||
Logger().information(Poco::format("SOCKET-ERROR(%s): Closing.",CId_));
|
||||
SendTelemetryShutdown();
|
||||
}
|
||||
|
||||
@@ -273,16 +273,16 @@ namespace OpenWifi {
|
||||
}
|
||||
catch (const Poco::Exception & E)
|
||||
{
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
SendTelemetryShutdown();
|
||||
}
|
||||
catch (const std::exception & E) {
|
||||
std::string W = E.what();
|
||||
Logger_.information(Poco::format("std::exception caught: %s. Connection terminated with %s",W,CId_));
|
||||
Logger().information(Poco::format("std::exception caught: %s. Connection terminated with %s",W,CId_));
|
||||
SendTelemetryShutdown();
|
||||
}
|
||||
catch ( ... ) {
|
||||
Logger_.information(Poco::format("Unknown exception for %s. Connection terminated.",CId_));
|
||||
Logger().information(Poco::format("Unknown exception for %s. Connection terminated.",CId_));
|
||||
SendTelemetryShutdown();
|
||||
}
|
||||
}
|
||||
@@ -299,16 +299,16 @@ namespace OpenWifi {
|
||||
Op = flags & Poco::Net::WebSocket::FRAME_OP_BITMASK;
|
||||
|
||||
if (IncomingSize == 0 && flags == 0 && Op == 0) {
|
||||
Logger_.information(Poco::format("DISCONNECT(%s): device has disconnected.", CId_));
|
||||
Logger().information(Poco::format("DISCONNECT(%s): device has disconnected.", CId_));
|
||||
MustDisconnect = true;
|
||||
} else {
|
||||
if (Op == Poco::Net::WebSocket::FRAME_OP_PING) {
|
||||
Logger_.debug(Poco::format("WS-PING(%s): received. PONG sent back.", CId_));
|
||||
Logger().debug(Poco::format("WS-PING(%s): received. PONG sent back.", CId_));
|
||||
WS_->sendFrame("", 0,
|
||||
(int)Poco::Net::WebSocket::FRAME_OP_PONG |
|
||||
(int)Poco::Net::WebSocket::FRAME_FLAG_FIN);
|
||||
} else if (Op == Poco::Net::WebSocket::FRAME_OP_CLOSE) {
|
||||
Logger_.information(Poco::format("DISCONNECT(%s): device wants to disconnect.", CId_));
|
||||
Logger().information(Poco::format("DISCONNECT(%s): device wants to disconnect.", CId_));
|
||||
MustDisconnect = true ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace OpenWifi {
|
||||
void OnSocketError(const Poco::AutoPtr<Poco::Net::ErrorNotification>& pNf);
|
||||
bool Send(const std::string &Payload);
|
||||
void ProcessIncomingFrame();
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
private:
|
||||
std::recursive_mutex Mutex_;
|
||||
std::string UUID_;
|
||||
|
||||
@@ -32,9 +32,9 @@ namespace OpenWifi {
|
||||
|
||||
bool WebSocketServer::ValidateCertificate(const std::string & ConnectionId, const Poco::Crypto::X509Certificate & Certificate) {
|
||||
if(IsCertOk()) {
|
||||
Logger_.debug(Poco::format("CERTIFICATE(%s): issuer='%s' cn='%s'", ConnectionId, Certificate.issuerName(),Certificate.commonName()));
|
||||
Logger().debug(Poco::format("CERTIFICATE(%s): issuer='%s' cn='%s'", ConnectionId, Certificate.issuerName(),Certificate.commonName()));
|
||||
if(!Certificate.issuedBy(*IssuerCert_)) {
|
||||
Logger_.debug(Poco::format("CERTIFICATE(%s): issuer mismatch. Local='%s' Incoming='%s'", ConnectionId, IssuerCert_->issuerName(), Certificate.issuerName()));
|
||||
Logger().debug(Poco::format("CERTIFICATE(%s): issuer mismatch. Local='%s' Incoming='%s'", ConnectionId, IssuerCert_->issuerName(), Certificate.issuerName()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -45,18 +45,18 @@ namespace OpenWifi {
|
||||
int WebSocketServer::Start() {
|
||||
ReactorPool_.Start();
|
||||
for(const auto & Svr : ConfigServersList_ ) {
|
||||
Logger_.notice(Poco::format("Starting: %s:%s Keyfile:%s CertFile: %s", Svr.Address(), std::to_string(Svr.Port()),
|
||||
Logger().notice(Poco::format("Starting: %s:%s Keyfile:%s CertFile: %s", Svr.Address(), std::to_string(Svr.Port()),
|
||||
Svr.KeyFile(),Svr.CertFile()));
|
||||
|
||||
Svr.LogCert(Logger_);
|
||||
Svr.LogCert(Logger());
|
||||
if(!Svr.RootCA().empty())
|
||||
Svr.LogCas(Logger_);
|
||||
Svr.LogCas(Logger());
|
||||
|
||||
auto Sock{Svr.CreateSecureSocket(Logger_)};
|
||||
auto Sock{Svr.CreateSecureSocket(Logger())};
|
||||
|
||||
if(!IsCertOk()) {
|
||||
IssuerCert_ = std::make_unique<Poco::Crypto::X509Certificate>(Svr.IssuerCertFile());
|
||||
Logger_.information(Poco::format("Certificate Issuer Name:%s",IssuerCert_->issuerName()));
|
||||
Logger().information(Poco::format("Certificate Issuer Name:%s",IssuerCert_->issuerName()));
|
||||
}
|
||||
auto NewSocketAcceptor = std::make_unique<Poco::Net::ParallelSocketAcceptor<WSConnection, Poco::Net::SocketReactor>>(Sock, Reactor_);
|
||||
Acceptors_.push_back(std::move(NewSocketAcceptor));
|
||||
@@ -70,14 +70,14 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void WebSocketServer::Stop() {
|
||||
Logger_.notice("Stopping reactors...");
|
||||
Logger().notice("Stopping reactors...");
|
||||
ReactorPool_.Stop();
|
||||
Reactor_.stop();
|
||||
ReactorThread_.join();
|
||||
}
|
||||
|
||||
void WSConnection::LogException(const Poco::Exception &E) {
|
||||
Logger_.information(Poco::format("EXCEPTION(%s): %s",CId_,E.displayText()));
|
||||
Logger().information(Poco::format("EXCEPTION(%s): %s",CId_,E.displayText()));
|
||||
}
|
||||
|
||||
void WSConnection::CompleteStartup() {
|
||||
@@ -90,9 +90,9 @@ namespace OpenWifi {
|
||||
PeerAddress_ = SS->peerAddress().host();
|
||||
CId_ = Utils::FormatIPv6(SS->peerAddress().toString());
|
||||
if (!SS->secure()) {
|
||||
Logger_.error(Poco::format("%s: Connection is NOT secure.", CId_));
|
||||
Logger().error(Poco::format("%s: Connection is NOT secure.", CId_));
|
||||
} else {
|
||||
Logger_.debug(Poco::format("%s: Connection is secure.", CId_));
|
||||
Logger().debug(Poco::format("%s: Connection is secure.", CId_));
|
||||
}
|
||||
|
||||
if (SS->havePeerCertificate()) {
|
||||
@@ -104,26 +104,26 @@ namespace OpenWifi {
|
||||
if (WebSocketServer()->ValidateCertificate(CId_, PeerCert)) {
|
||||
CN_ = Poco::trim(Poco::toLower(PeerCert.commonName()));
|
||||
CertValidation_ = GWObjects::MISMATCH_SERIAL;
|
||||
Logger_.debug(Poco::format("%s: Valid certificate: CN=%s", CId_, CN_));
|
||||
Logger().debug(Poco::format("%s: Valid certificate: CN=%s", CId_, CN_));
|
||||
} else {
|
||||
Logger_.debug(Poco::format("%s: Certificate is not valid", CId_));
|
||||
Logger().debug(Poco::format("%s: Certificate is not valid", CId_));
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
LogException(E);
|
||||
}
|
||||
} else {
|
||||
Logger_.error(Poco::format("%s: No certificates available..", CId_));
|
||||
Logger().error(Poco::format("%s: No certificates available..", CId_));
|
||||
}
|
||||
|
||||
if(WebSocketServer::IsSim(CN_) && !WebSocketServer()->IsSimEnabled()) {
|
||||
Logger_.debug(Poco::format("CONNECTION(%s): Sim Device %s is not allowed. Disconnecting.", CId_, CN_));
|
||||
Logger().debug(Poco::format("CONNECTION(%s): Sim Device %s is not allowed. Disconnecting.", CId_, CN_));
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
||||
SerialNumber_ = CN_;
|
||||
if(!CN_.empty() && StorageService()->IsBlackListed(SerialNumber_)) {
|
||||
Logger_.debug(Poco::format("CONNECTION(%s): Device %s is black listed. Disconnecting.", CId_, CN_));
|
||||
Logger().debug(Poco::format("CONNECTION(%s): Device %s is black listed. Disconnecting.", CId_, CN_));
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
@@ -153,13 +153,13 @@ namespace OpenWifi {
|
||||
Poco::NObserver<WSConnection, Poco::Net::ErrorNotification>(
|
||||
*this, &WSConnection::OnSocketError));
|
||||
Registered_ = true;
|
||||
Logger_.information(Poco::format("CONNECTION(%s): completed.",CId_));
|
||||
Logger().information(Poco::format("CONNECTION(%s): completed.",CId_));
|
||||
return;
|
||||
} catch (const Poco::Exception &E ) {
|
||||
Logger_.error("Exception caught during device connection. Device will have to retry.");
|
||||
Logger_.log(E);
|
||||
Logger().error("Exception caught during device connection. Device will have to retry.");
|
||||
Logger().log(E);
|
||||
} catch (...) {
|
||||
Logger_.error("Exception caught during device connection. Device will have to retry. Unsecure connect denied.");
|
||||
Logger().error("Exception caught during device connection. Device will have to retry. Unsecure connect denied.");
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ namespace OpenWifi {
|
||||
Cmd.Details = O.str();
|
||||
|
||||
std::string Log = Poco::format("CFG-UPGRADE(%s): Current ID: %Lu, newer configuration %Lu.", CId_, UUID, D.UUID);
|
||||
Logger_.debug(Log);
|
||||
Logger().debug(Log);
|
||||
uint64_t RPC_Id;
|
||||
CommandManager()->SendCommand(SerialNumber_ , Cmd.Command, Params, Cmd.UUID, RPC_Id);
|
||||
StorageService()->AddCommand(SerialNumber_, Cmd, Storage::COMMAND_EXECUTED);
|
||||
@@ -290,14 +290,14 @@ namespace OpenWifi {
|
||||
auto Method = Doc->get(uCentralProtocol::METHOD).toString();
|
||||
auto EventType = uCentralProtocol::EventFromString(Method);
|
||||
if(EventType == uCentralProtocol::ET_UNKNOWN) {
|
||||
Logger_.error(Poco::format("ILLEGAL-PROTOCOL(%s): Unknown message type '%s'",Method));
|
||||
Logger().error(Poco::format("ILLEGAL-PROTOCOL(%s): Unknown message type '%s'",Method));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Doc->isObject(uCentralProtocol::PARAMS))
|
||||
{
|
||||
Logger_.warning(Poco::format("MISSING-PARAMS(%s): params must be an object.",CId_));
|
||||
Logger().warning(Poco::format("MISSING-PARAMS(%s): params must be an object.",CId_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -308,11 +308,11 @@ namespace OpenWifi {
|
||||
{
|
||||
std::string UncompressedData;
|
||||
if(ExtractCompressedData(ParamsObj->get(uCentralProtocol::COMPRESS_64).toString(),UncompressedData)) {
|
||||
Logger_.debug(Poco::format("EVENT(%s): Found compressed payload expanded to '%s'.",CId_, UncompressedData));
|
||||
Logger().debug(Poco::format("EVENT(%s): Found compressed payload expanded to '%s'.",CId_, UncompressedData));
|
||||
Poco::JSON::Parser Parser;
|
||||
ParamsObj = Parser.parse(UncompressedData).extract<Poco::JSON::Object::Ptr>();
|
||||
} else {
|
||||
Logger_.warning(Poco::format("INVALID-COMPRESSED-DATA(%s): Compressed cannot be uncompressed - content must be corrupt..",CId_));
|
||||
Logger().warning(Poco::format("INVALID-COMPRESSED-DATA(%s): Compressed cannot be uncompressed - content must be corrupt..",CId_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -320,7 +320,7 @@ namespace OpenWifi {
|
||||
|
||||
if(!ParamsObj->has(uCentralProtocol::SERIAL))
|
||||
{
|
||||
Logger_.warning(Poco::format("MISSING-PARAMS(%s): Serial number is missing in message.",CId_));
|
||||
Logger().warning(Poco::format("MISSING-PARAMS(%s): Serial number is missing in message.",CId_));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -360,12 +360,12 @@ namespace OpenWifi {
|
||||
// We need to verify the certificate if we have one
|
||||
if((!CN_.empty() && Utils::SerialNumberMatch(CN_,SerialNumber_)) || WebSocketServer()->IsSimSerialNumber(CN_)) {
|
||||
CertValidation_ = GWObjects::VERIFIED;
|
||||
Logger_.information(Poco::format("CONNECT(%s): Fully validated and authenticated device..", CId_));
|
||||
Logger().information(Poco::format("CONNECT(%s): Fully validated and authenticated device..", CId_));
|
||||
} else {
|
||||
if(CN_.empty())
|
||||
Logger_.information(Poco::format("CONNECT(%s): Not authenticated or validated.", CId_));
|
||||
Logger().information(Poco::format("CONNECT(%s): Not authenticated or validated.", CId_));
|
||||
else
|
||||
Logger_.information(Poco::format("CONNECT(%s): Authenticated but not validated. Serial='%s' CN='%s'", CId_, Serial, CN_));
|
||||
Logger().information(Poco::format("CONNECT(%s): Authenticated but not validated. Serial='%s' CN='%s'", CId_, Serial, CN_));
|
||||
}
|
||||
Conn_->Conn_.VerifiedCertificate = CertValidation_;
|
||||
|
||||
@@ -382,7 +382,7 @@ namespace OpenWifi {
|
||||
LookForUpgrade(UUID);
|
||||
}
|
||||
|
||||
StatsProcessor_ = std::make_unique<StateProcessor>(Conn_, Logger_);
|
||||
StatsProcessor_ = std::make_unique<StateProcessor>(Conn_, Logger());
|
||||
StatsProcessor_->Initialize(Serial);
|
||||
|
||||
if(KafkaManager()->Enabled()) {
|
||||
@@ -394,7 +394,7 @@ namespace OpenWifi {
|
||||
}
|
||||
Connected_ = true;
|
||||
} else {
|
||||
Logger_.warning(Poco::format("CONNECT(%s): Missing one of uuid, firmware, or capabilities",CId_));
|
||||
Logger().warning(Poco::format("CONNECT(%s): Missing one of uuid, firmware, or capabilities",CId_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ namespace OpenWifi {
|
||||
|
||||
case uCentralProtocol::ET_STATE: {
|
||||
if(!Connected_) {
|
||||
Logger_.debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Logger().debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -416,9 +416,9 @@ namespace OpenWifi {
|
||||
request_uuid = ParamsObj->get(uCentralProtocol::REQUEST_UUID).toString();
|
||||
|
||||
if (request_uuid.empty())
|
||||
Logger_.debug(Poco::format("STATE(%s): UUID=%Lu Updating.", CId_, UUID));
|
||||
Logger().debug(Poco::format("STATE(%s): UUID=%Lu Updating.", CId_, UUID));
|
||||
else
|
||||
Logger_.debug(Poco::format("STATE(%s): UUID=%Lu Updating for CMD=%s.", CId_,
|
||||
Logger().debug(Poco::format("STATE(%s): UUID=%Lu Updating for CMD=%s.", CId_,
|
||||
UUID, request_uuid));
|
||||
Conn_->Conn_.UUID = UUID;
|
||||
LookForUpgrade(UUID);
|
||||
@@ -438,7 +438,7 @@ namespace OpenWifi {
|
||||
KafkaManager()->PostMessage(KafkaTopics::STATE, SerialNumber_, OS.str());
|
||||
}
|
||||
} else {
|
||||
Logger_.warning(Poco::format(
|
||||
Logger().warning(Poco::format(
|
||||
"STATE(%s): Invalid request. Missing serial, uuid, or state", CId_));
|
||||
}
|
||||
}
|
||||
@@ -446,7 +446,7 @@ namespace OpenWifi {
|
||||
|
||||
case uCentralProtocol::ET_HEALTHCHECK: {
|
||||
if(!Connected_) {
|
||||
Logger_.debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Logger().debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -462,10 +462,10 @@ namespace OpenWifi {
|
||||
request_uuid = ParamsObj->get(uCentralProtocol::REQUEST_UUID).toString();
|
||||
|
||||
if (request_uuid.empty())
|
||||
Logger_.debug(
|
||||
Logger().debug(
|
||||
Poco::format("HEALTHCHECK(%s): UUID=%Lu Updating.", CId_, UUID));
|
||||
else
|
||||
Logger_.debug(Poco::format("HEALTHCHECK(%s): UUID=%Lu Updating for CMD=%s.",
|
||||
Logger().debug(Poco::format("HEALTHCHECK(%s): UUID=%Lu Updating for CMD=%s.",
|
||||
CId_, UUID, request_uuid));
|
||||
|
||||
Conn_->Conn_.UUID = UUID;
|
||||
@@ -494,7 +494,7 @@ namespace OpenWifi {
|
||||
KafkaManager()->PostMessage(KafkaTopics::HEALTHCHECK, SerialNumber_, OS.str());
|
||||
}
|
||||
} else {
|
||||
Logger_.warning(Poco::format("HEALTHCHECK(%s): Missing parameter", CId_));
|
||||
Logger().warning(Poco::format("HEALTHCHECK(%s): Missing parameter", CId_));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -502,12 +502,12 @@ namespace OpenWifi {
|
||||
|
||||
case uCentralProtocol::ET_LOG: {
|
||||
if(!Connected_) {
|
||||
Logger_.debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Logger().debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
if (ParamsObj->has(uCentralProtocol::LOG) && ParamsObj->has(uCentralProtocol::SEVERITY)) {
|
||||
Logger_.debug(Poco::format("LOG(%s): new entry.", CId_));
|
||||
Logger().debug(Poco::format("LOG(%s): new entry.", CId_));
|
||||
auto Log = ParamsObj->get(uCentralProtocol::LOG).toString();
|
||||
auto Severity = ParamsObj->get(uCentralProtocol::SEVERITY);
|
||||
std::string DataStr = uCentralProtocol::EMPTY_JSON_DOC;
|
||||
@@ -526,7 +526,7 @@ namespace OpenWifi {
|
||||
.UUID = Conn_->Conn_.UUID};
|
||||
StorageService()->AddLog(DeviceLog);
|
||||
} else {
|
||||
Logger_.warning(Poco::format("LOG(%s): Missing parameters.", CId_));
|
||||
Logger().warning(Poco::format("LOG(%s): Missing parameters.", CId_));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -535,7 +535,7 @@ namespace OpenWifi {
|
||||
case uCentralProtocol::ET_CRASHLOG: {
|
||||
if (ParamsObj->has(uCentralProtocol::UUID) && ParamsObj->has(uCentralProtocol::LOGLINES)) {
|
||||
|
||||
Logger_.debug(Poco::format("CRASH-LOG(%s): new entry.", CId_));
|
||||
Logger().debug(Poco::format("CRASH-LOG(%s): new entry.", CId_));
|
||||
auto LogLines = ParamsObj->get(uCentralProtocol::LOGLINES);
|
||||
std::string LogText;
|
||||
if (LogLines.isArray()) {
|
||||
@@ -555,7 +555,7 @@ namespace OpenWifi {
|
||||
StorageService()->AddLog(DeviceLog);
|
||||
|
||||
} else {
|
||||
Logger_.warning(Poco::format("LOG(%s): Missing parameters.", CId_));
|
||||
Logger().warning(Poco::format("LOG(%s): Missing parameters.", CId_));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -564,16 +564,16 @@ namespace OpenWifi {
|
||||
case uCentralProtocol::ET_PING: {
|
||||
if (ParamsObj->has(uCentralProtocol::UUID)) {
|
||||
uint64_t UUID = ParamsObj->get(uCentralProtocol::UUID);
|
||||
Logger_.debug(Poco::format("PING(%s): Current config is %Lu", CId_, UUID));
|
||||
Logger().debug(Poco::format("PING(%s): Current config is %Lu", CId_, UUID));
|
||||
} else {
|
||||
Logger_.warning(Poco::format("PING(%s): Missing parameter.", CId_));
|
||||
Logger().warning(Poco::format("PING(%s): Missing parameter.", CId_));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case uCentralProtocol::ET_CFGPENDING: {
|
||||
if(!Connected_) {
|
||||
Logger_.debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Logger().debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -582,10 +582,10 @@ namespace OpenWifi {
|
||||
uint64_t UUID = ParamsObj->get(uCentralProtocol::UUID);
|
||||
uint64_t Active = ParamsObj->get(uCentralProtocol::ACTIVE);
|
||||
|
||||
Logger_.debug(Poco::format("CFG-PENDING(%s): Active: %Lu Target: %Lu", CId_,
|
||||
Logger().debug(Poco::format("CFG-PENDING(%s): Active: %Lu Target: %Lu", CId_,
|
||||
Active, UUID));
|
||||
} else {
|
||||
Logger_.warning(Poco::format("CFG-PENDING(%s): Missing some parameters", CId_));
|
||||
Logger().warning(Poco::format("CFG-PENDING(%s): Missing some parameters", CId_));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -632,12 +632,12 @@ namespace OpenWifi {
|
||||
uint64_t RPC_Id;
|
||||
CommandManager()->SendCommand(SerialNumber_ , Cmd.Command, Params, Cmd.UUID, RPC_Id);
|
||||
StorageService()->AddCommand(SerialNumber_, Cmd, Storage::COMMAND_EXECUTED);
|
||||
Logger_.information(Poco::format("RECOVERY(%s): Recovery mode received, need for a reboot.",CId_));
|
||||
Logger().information(Poco::format("RECOVERY(%s): Recovery mode received, need for a reboot.",CId_));
|
||||
} else {
|
||||
Logger_.information(Poco::format("RECOVERY(%s): Recovery mode received, no need for a reboot.",CId_));
|
||||
Logger().information(Poco::format("RECOVERY(%s): Recovery mode received, no need for a reboot.",CId_));
|
||||
}
|
||||
} else {
|
||||
Logger_.error(Poco::format(
|
||||
Logger().error(Poco::format(
|
||||
"RECOVERY(%s): Recovery missing one of serialnumber, firmware, uuid, loglines, reboot",
|
||||
Serial));
|
||||
}
|
||||
@@ -646,7 +646,7 @@ namespace OpenWifi {
|
||||
|
||||
case uCentralProtocol::ET_DEVICEUPDATE: {
|
||||
if(!Connected_) {
|
||||
Logger_.debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Logger().debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -654,7 +654,7 @@ namespace OpenWifi {
|
||||
auto Password = ParamsObj->get("currentPassword").toString();
|
||||
|
||||
StorageService()->SetDevicePassword(Serial, Password);
|
||||
Logger_.error(Poco::format(
|
||||
Logger().error(Poco::format(
|
||||
"DEVICEUPDATE(%s): Device is updating its login password.", Serial));
|
||||
}
|
||||
}
|
||||
@@ -662,7 +662,7 @@ namespace OpenWifi {
|
||||
|
||||
case uCentralProtocol::ET_TELEMETRY: {
|
||||
if(!Connected_) {
|
||||
Logger_.debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Logger().debug(Poco::format("INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -676,7 +676,7 @@ namespace OpenWifi {
|
||||
// this will never be called but some compilers will complain if we do not have a case for
|
||||
// every single values of an enum
|
||||
case uCentralProtocol::ET_UNKNOWN: {
|
||||
Logger_.error(Poco::format("ILLEGAL-EVENT(%s): Event '%s' unknown. CN=%s", CId_, Method, CN_));
|
||||
Logger().error(Poco::format("ILLEGAL-EVENT(%s): Event '%s' unknown. CN=%s", CId_, Method, CN_));
|
||||
Errors_++;
|
||||
}
|
||||
}
|
||||
@@ -684,13 +684,13 @@ namespace OpenWifi {
|
||||
|
||||
void WSConnection::OnSocketShutdown(const Poco::AutoPtr<Poco::Net::ShutdownNotification>& pNf) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
Logger_.information(Poco::format("SOCKET-SHUTDOWN(%s): Closing.",CId_));
|
||||
Logger().information(Poco::format("SOCKET-SHUTDOWN(%s): Closing.",CId_));
|
||||
delete this;
|
||||
}
|
||||
|
||||
void WSConnection::OnSocketError(const Poco::AutoPtr<Poco::Net::ErrorNotification>& pNf) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
Logger_.information(Poco::format("SOCKET-ERROR(%s): Closing.",CId_));
|
||||
Logger().information(Poco::format("SOCKET-ERROR(%s): Closing.",CId_));
|
||||
delete this;
|
||||
}
|
||||
|
||||
@@ -702,16 +702,16 @@ namespace OpenWifi {
|
||||
}
|
||||
catch (const Poco::Exception & E)
|
||||
{
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
delete this;
|
||||
}
|
||||
catch (const std::exception & E) {
|
||||
std::string W = E.what();
|
||||
Logger_.information(Poco::format("std::exception caught: %s. Connection terminated with %s",W,CId_));
|
||||
Logger().information(Poco::format("std::exception caught: %s. Connection terminated with %s",W,CId_));
|
||||
delete this;
|
||||
}
|
||||
catch ( ... ) {
|
||||
Logger_.information(Poco::format("Unknown exception for %s. Connection terminated.",CId_));
|
||||
Logger().information(Poco::format("Unknown exception for %s. Connection terminated.",CId_));
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
@@ -736,7 +736,7 @@ namespace OpenWifi {
|
||||
Op = flags & Poco::Net::WebSocket::FRAME_OP_BITMASK;
|
||||
|
||||
if (IncomingSize == 0 && flags == 0 && Op == 0) {
|
||||
Logger_.information(Poco::format("DISCONNECT(%s): device has disconnected.", CId_));
|
||||
Logger().information(Poco::format("DISCONNECT(%s): device has disconnected.", CId_));
|
||||
return delete this;
|
||||
} else {
|
||||
|
||||
@@ -747,7 +747,7 @@ namespace OpenWifi {
|
||||
|
||||
switch (Op) {
|
||||
case Poco::Net::WebSocket::FRAME_OP_PING: {
|
||||
Logger_.debug(Poco::format("WS-PING(%s): received. PONG sent back.", CId_));
|
||||
Logger().debug(Poco::format("WS-PING(%s): received. PONG sent back.", CId_));
|
||||
WS_->sendFrame("", 0,
|
||||
(int)Poco::Net::WebSocket::FRAME_OP_PONG |
|
||||
(int)Poco::Net::WebSocket::FRAME_FLAG_FIN);
|
||||
@@ -774,14 +774,14 @@ namespace OpenWifi {
|
||||
break;
|
||||
|
||||
case Poco::Net::WebSocket::FRAME_OP_PONG: {
|
||||
Logger_.debug(Poco::format("PONG(%s): received and ignored.",CId_));
|
||||
Logger().debug(Poco::format("PONG(%s): received and ignored.",CId_));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case Poco::Net::WebSocket::FRAME_OP_TEXT: {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
Logger_.debug(Poco::format("FRAME(%s): Frame received (length=%d, flags=0x%x). Msg=%s",
|
||||
Logger().debug(Poco::format("FRAME(%s): Frame received (length=%d, flags=0x%x). Msg=%s",
|
||||
CId_, IncomingSize, unsigned(flags),IncomingMessageStr));
|
||||
|
||||
Poco::JSON::Parser parser;
|
||||
@@ -794,15 +794,15 @@ namespace OpenWifi {
|
||||
ProcessJSONRPCEvent(IncomingJSON);
|
||||
} else if (IncomingJSON->has(uCentralProtocol::RESULT) &&
|
||||
IncomingJSON->has(uCentralProtocol::ID)) {
|
||||
Logger_.debug(Poco::format("RPC-RESULT(%s): payload: %s",CId_,IncomingMessageStr));
|
||||
Logger().debug(Poco::format("RPC-RESULT(%s): payload: %s",CId_,IncomingMessageStr));
|
||||
ProcessJSONRPCResult(IncomingJSON);
|
||||
} else {
|
||||
Logger_.warning(Poco::format(
|
||||
Logger().warning(Poco::format(
|
||||
"INVALID-PAYLOAD(%s): Payload is not JSON-RPC 2.0: %s", CId_,
|
||||
IncomingMessageStr));
|
||||
}
|
||||
} else {
|
||||
Logger_.error(Poco::format("FRAME(%s): illegal transaction header, missing 'jsonrpc'",CId_));
|
||||
Logger().error(Poco::format("FRAME(%s): illegal transaction header, missing 'jsonrpc'",CId_));
|
||||
Errors_++;
|
||||
}
|
||||
return;
|
||||
@@ -810,13 +810,13 @@ namespace OpenWifi {
|
||||
break;
|
||||
|
||||
case Poco::Net::WebSocket::FRAME_OP_CLOSE: {
|
||||
Logger_.warning(Poco::format("CLOSE(%s): Device is closing its connection.",CId_));
|
||||
Logger().warning(Poco::format("CLOSE(%s): Device is closing its connection.",CId_));
|
||||
return delete this;
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
Logger_.warning(Poco::format("UNKNOWN(%s): unknownWS Frame operation: %s",CId_, std::to_string(Op)));
|
||||
Logger().warning(Poco::format("UNKNOWN(%s): unknownWS Frame operation: %s",CId_, std::to_string(Op)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -825,58 +825,58 @@ namespace OpenWifi {
|
||||
catch (const Poco::Net::ConnectionResetException & E)
|
||||
{
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
Logger_.warning(Poco::format("%s(%s): Caught a ConnectionResetException: %s, Message: %s",
|
||||
Logger().warning(Poco::format("%s(%s): Caught a ConnectionResetException: %s, Message: %s",
|
||||
std::string(__func__), CId_, E.displayText(),IncomingMessageStr));
|
||||
return delete this;
|
||||
}
|
||||
catch (const Poco::JSON::JSONException & E)
|
||||
{
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
Logger_.warning(Poco::format("%s(%s): Caught a JSONException: %s. Message: %s",
|
||||
Logger().warning(Poco::format("%s(%s): Caught a JSONException: %s. Message: %s",
|
||||
std::string(__func__), CId_, E.displayText(), IncomingMessageStr ));
|
||||
}
|
||||
catch (const Poco::Net::WebSocketException & E)
|
||||
{
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
Logger_.warning(Poco::format("%s(%s): Caught a websocket exception: %s. Message: %s",
|
||||
Logger().warning(Poco::format("%s(%s): Caught a websocket exception: %s. Message: %s",
|
||||
std::string(__func__), CId_, E.displayText(), IncomingMessageStr ));
|
||||
return delete this;
|
||||
}
|
||||
catch (const Poco::Net::SSLConnectionUnexpectedlyClosedException & E)
|
||||
{
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
Logger_.warning(Poco::format("%s(%s): Caught a SSLConnectionUnexpectedlyClosedException: %s. Message: %s",
|
||||
Logger().warning(Poco::format("%s(%s): Caught a SSLConnectionUnexpectedlyClosedException: %s. Message: %s",
|
||||
std::string(__func__), CId_, E.displayText(), IncomingMessageStr ));
|
||||
return delete this;
|
||||
}
|
||||
catch (const Poco::Net::SSLException & E)
|
||||
{
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
Logger_.warning(Poco::format("%s(%s): Caught a SSL exception: %s. Message: %s",
|
||||
Logger().warning(Poco::format("%s(%s): Caught a SSL exception: %s. Message: %s",
|
||||
std::string(__func__), CId_, E.displayText(), IncomingMessageStr ));
|
||||
return delete this;
|
||||
}
|
||||
catch (const Poco::Net::NetException & E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
Logger_.warning( Poco::format("%s(%s): Caught a NetException: %s. Message: %s",
|
||||
Logger().warning( Poco::format("%s(%s): Caught a NetException: %s. Message: %s",
|
||||
std::string(__func__), CId_, E.displayText(), IncomingMessageStr ));
|
||||
return delete this;
|
||||
}
|
||||
catch (const Poco::IOException & E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
Logger_.warning( Poco::format("%s(%s): Caught a IOException: %s. Message: %s",
|
||||
Logger().warning( Poco::format("%s(%s): Caught a IOException: %s. Message: %s",
|
||||
std::string(__func__), CId_, E.displayText(), IncomingMessageStr ));
|
||||
return delete this;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
Logger_.warning( Poco::format("%s(%s): Caught a more generic Poco exception: %s. Message: %s",
|
||||
Logger().warning( Poco::format("%s(%s): Caught a more generic Poco exception: %s. Message: %s",
|
||||
std::string(__func__), CId_, E.displayText(), IncomingMessageStr ));
|
||||
return delete this;
|
||||
}
|
||||
catch (const std::exception & E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
Logger_.warning( Poco::format("%s(%s): Caught a std::exception: %s. Message: %s",
|
||||
Logger().warning( Poco::format("%s(%s): Caught a std::exception: %s. Message: %s",
|
||||
std::string{__func__}, CId_, std::string{E.what()}, IncomingMessageStr) );
|
||||
return delete this;
|
||||
}
|
||||
@@ -887,7 +887,7 @@ namespace OpenWifi {
|
||||
if(Errors_<10)
|
||||
return;
|
||||
|
||||
Logger_.information(Poco::format("DISCONNECTING(%s): Too many errors",CId_));
|
||||
Logger().information(Poco::format("DISCONNECTING(%s): Too many errors",CId_));
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ namespace OpenWifi {
|
||||
static bool ExtractCompressedData(const std::string & CompressedData, std::string & UnCompressedData);
|
||||
void LogException(const Poco::Exception &E);
|
||||
[[nodiscard]] GWObjects::CertificateValidation CertificateValidation() const { return CertValidation_; };
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
private:
|
||||
std::recursive_mutex Mutex_;
|
||||
Poco::Logger &Logger_;
|
||||
|
||||
@@ -2327,7 +2327,7 @@ namespace OpenWifi {
|
||||
if(Utils::wgets(GitUCentralJSONSchemaFile, GitSchema)) {
|
||||
auto schema = json::parse(GitSchema);
|
||||
Validator_->set_root_schema(schema);
|
||||
Logger_.information("Using uCentral validation schema from GIT.");
|
||||
Logger().information("Using uCentral validation schema from GIT.");
|
||||
} else {
|
||||
std::string FileName{ MicroService::instance().DataDir() + "/ucentral.schema.json" };
|
||||
std::ifstream input(FileName);
|
||||
@@ -2336,11 +2336,11 @@ namespace OpenWifi {
|
||||
input.close();
|
||||
auto schema = json::parse(schema_file.str());
|
||||
Validator_->set_root_schema(schema);
|
||||
Logger_.information("Using uCentral validation schema from local file.");
|
||||
Logger().information("Using uCentral validation schema from local file.");
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
Validator_->set_root_schema(DefaultUCentralSchema);
|
||||
Logger_.information("Using uCentral validation from built-in default.");
|
||||
Logger().information("Using uCentral validation from built-in default.");
|
||||
}
|
||||
Initialized_ = Working_ = true;
|
||||
}
|
||||
@@ -2471,7 +2471,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void ConfigurationValidator::reinitialize(Poco::Util::Application &self) {
|
||||
Logger_.information("Reinitializing.");
|
||||
Logger().information("Reinitializing.");
|
||||
Working_ = Initialized_ = false;
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,13 @@ using namespace std::chrono_literals;
|
||||
#include "Poco/JSON/Object.h"
|
||||
#include "Poco/JSON/Parser.h"
|
||||
#include "Poco/StringTokenizer.h"
|
||||
#include "Poco/AsyncChannel.h"
|
||||
#include "Poco/ConsoleChannel.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include "Poco/FormattingChannel.h"
|
||||
#include "Poco/PatternFormatter.h"
|
||||
#include "Poco/FileChannel.h"
|
||||
#include "Poco/SimpleFileChannel.h"
|
||||
|
||||
#include "cppkafka/cppkafka.h"
|
||||
|
||||
@@ -74,6 +81,8 @@ using namespace std::chrono_literals;
|
||||
|
||||
#include "ow_version.h"
|
||||
|
||||
#define _OWDEBUG_ std::cout<< __FILE__ <<":" << __LINE__ << std::endl;
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
enum UNAUTHORIZED_REASON {
|
||||
@@ -95,7 +104,7 @@ namespace OpenWifi {
|
||||
inline AppServiceRegistry();
|
||||
|
||||
static AppServiceRegistry & instance() {
|
||||
static AppServiceRegistry *instance_= new AppServiceRegistry;
|
||||
static auto instance_= new AppServiceRegistry;
|
||||
return *instance_;
|
||||
}
|
||||
|
||||
@@ -1311,17 +1320,13 @@ namespace OpenWifi {
|
||||
class SubSystemServer : public Poco::Util::Application::Subsystem {
|
||||
public:
|
||||
SubSystemServer(std::string Name, const std::string &LoggingPrefix,
|
||||
std::string SubSystemConfigPrefix)
|
||||
: Name_(std::move(Name)), Logger_(Poco::Logger::get(LoggingPrefix)),
|
||||
SubSystemConfigPrefix_(std::move(SubSystemConfigPrefix)) {
|
||||
Logger_.setLevel(Poco::Message::PRIO_NOTICE);
|
||||
}
|
||||
std::string SubSystemConfigPrefix);
|
||||
|
||||
inline void initialize(Poco::Util::Application &self) override;
|
||||
inline void uninitialize() override {
|
||||
}
|
||||
inline void reinitialize(Poco::Util::Application &self) override {
|
||||
Logger_.information("Reloading of this subsystem is not supported.");
|
||||
Logger().information("Reloading of this subsystem is not supported.");
|
||||
}
|
||||
inline void defineOptions(Poco::Util::OptionSet &options) override {
|
||||
}
|
||||
@@ -1330,18 +1335,29 @@ namespace OpenWifi {
|
||||
|
||||
inline const PropertiesFileServerEntry & Host(uint64_t index) { return ConfigServersList_[index]; };
|
||||
inline uint64_t HostSize() const { return ConfigServersList_.size(); }
|
||||
inline Poco::Logger &Logger() { return Logger_; };
|
||||
inline void SetLoggingLevel(Poco::Message::Priority NewPriority) { Logger_.setLevel(NewPriority); }
|
||||
inline int GetLoggingLevel() { return Logger_.getLevel(); }
|
||||
inline Poco::Logger &Logger() { if(Log_)
|
||||
return Log_->L;
|
||||
return Poco::Logger::get("tmp");
|
||||
};
|
||||
inline void SetLoggingLevel(Poco::Message::Priority NewPriority) { Logger().setLevel(NewPriority); }
|
||||
inline int GetLoggingLevel() { return Logger().getLevel(); }
|
||||
|
||||
virtual int Start() = 0;
|
||||
virtual void Stop() = 0;
|
||||
|
||||
struct LoggerWrapper {
|
||||
Poco::Logger &L;
|
||||
inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {}
|
||||
};
|
||||
|
||||
protected:
|
||||
std::recursive_mutex Mutex_;
|
||||
Poco::Logger &Logger_;
|
||||
std::vector<PropertiesFileServerEntry> ConfigServersList_;
|
||||
private:
|
||||
std::unique_ptr<LoggerWrapper> Log_;
|
||||
// Poco::Logger &Logger_;
|
||||
std::string Name_;
|
||||
std::vector<PropertiesFileServerEntry> ConfigServersList_;
|
||||
std::string LoggerPrefix_;
|
||||
std::string SubSystemConfigPrefix_;
|
||||
};
|
||||
|
||||
@@ -1456,7 +1472,7 @@ namespace OpenWifi {
|
||||
};
|
||||
|
||||
static RESTAPI_RateLimiter *instance() {
|
||||
static RESTAPI_RateLimiter * instance_ = new RESTAPI_RateLimiter;
|
||||
static auto instance_ = new RESTAPI_RateLimiter;
|
||||
return instance_;
|
||||
}
|
||||
|
||||
@@ -1476,7 +1492,7 @@ namespace OpenWifi {
|
||||
E->Count++;
|
||||
Cache_.update(H,E);
|
||||
if(E->Count > MaxCalls) {
|
||||
Logger_.warning(Poco::format("RATE-LIMIT-EXCEEDED: from '%s'", R.clientAddress().toString()));
|
||||
Logger().warning(Poco::format("RATE-LIMIT-EXCEEDED: from '%s'", R.clientAddress().toString()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -2167,7 +2183,7 @@ namespace OpenWifi {
|
||||
inline void initialize(Poco::Util::Application & self) override;
|
||||
|
||||
static KafkaManager *instance() {
|
||||
static KafkaManager * instance_ = new KafkaManager;
|
||||
static auto instance_ = new KafkaManager;
|
||||
return instance_;
|
||||
}
|
||||
|
||||
@@ -2248,10 +2264,10 @@ namespace OpenWifi {
|
||||
KafkaConsumer ConsumerThr_;
|
||||
|
||||
inline void PartitionAssignment(const cppkafka::TopicPartitionList& partitions) {
|
||||
Logger_.information(Poco::format("Partition assigned: %Lu...",(uint64_t )partitions.front().get_partition()));
|
||||
Logger().information(Poco::format("Partition assigned: %Lu...",(uint64_t )partitions.front().get_partition()));
|
||||
}
|
||||
inline void PartitionRevocation(const cppkafka::TopicPartitionList& partitions) {
|
||||
Logger_.information(Poco::format("Partition revocation: %Lu...",(uint64_t )partitions.front().get_partition()));
|
||||
Logger().information(Poco::format("Partition revocation: %Lu...",(uint64_t )partitions.front().get_partition()));
|
||||
}
|
||||
|
||||
KafkaManager() noexcept:
|
||||
@@ -2270,7 +2286,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
static AuthClient *instance() {
|
||||
static AuthClient * instance_ = new AuthClient;
|
||||
static auto instance_ = new AuthClient;
|
||||
return instance_;
|
||||
}
|
||||
|
||||
@@ -2424,12 +2440,12 @@ namespace OpenWifi {
|
||||
class RESTAPI_ExtServer : public SubSystemServer {
|
||||
public:
|
||||
static RESTAPI_ExtServer *instance() {
|
||||
static RESTAPI_ExtServer *instance_ = new RESTAPI_ExtServer;
|
||||
static auto instance_ = new RESTAPI_ExtServer;
|
||||
return instance_;
|
||||
}
|
||||
int Start() override;
|
||||
inline void Stop() override {
|
||||
Logger_.information("Stopping ");
|
||||
Logger().information("Stopping ");
|
||||
for( const auto & svr : RESTServers_ )
|
||||
svr->stop();
|
||||
Pool_.joinAll();
|
||||
@@ -2440,7 +2456,7 @@ namespace OpenWifi {
|
||||
|
||||
inline Poco::Net::HTTPRequestHandler *CallServer(const char *Path, uint64_t Id) {
|
||||
RESTAPIHandler::BindingMap Bindings;
|
||||
return RESTAPI_ExtRouter(Path, Bindings, Logger_, Server_, Id);
|
||||
return RESTAPI_ExtRouter(Path, Bindings, Logger(), Server_, Id);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -2478,18 +2494,17 @@ namespace OpenWifi {
|
||||
};
|
||||
|
||||
inline int RESTAPI_ExtServer::Start() {
|
||||
Logger_.information("Starting.");
|
||||
Server_.InitLogging();
|
||||
|
||||
for(const auto & Svr: ConfigServersList_) {
|
||||
Logger_.information(Poco::format("Starting: %s:%s Keyfile:%s CertFile: %s", Svr.Address(), std::to_string(Svr.Port()),
|
||||
Logger().information(Poco::format("Starting: %s:%s Keyfile:%s CertFile: %s", Svr.Address(), std::to_string(Svr.Port()),
|
||||
Svr.KeyFile(),Svr.CertFile()));
|
||||
|
||||
auto Sock{Svr.CreateSecureSocket(Logger_)};
|
||||
auto Sock{Svr.CreateSecureSocket(Logger())};
|
||||
|
||||
Svr.LogCert(Logger_);
|
||||
Svr.LogCert(Logger());
|
||||
if(!Svr.RootCA().empty())
|
||||
Svr.LogCas(Logger_);
|
||||
Svr.LogCas(Logger());
|
||||
|
||||
Poco::Net::HTTPServerParams::Ptr Params = new Poco::Net::HTTPServerParams;
|
||||
Params->setMaxThreads(50);
|
||||
@@ -2508,13 +2523,13 @@ namespace OpenWifi {
|
||||
|
||||
public:
|
||||
static RESTAPI_IntServer *instance() {
|
||||
static RESTAPI_IntServer *instance_ = new RESTAPI_IntServer;
|
||||
static auto instance_ = new RESTAPI_IntServer;
|
||||
return instance_;
|
||||
}
|
||||
|
||||
inline int Start() override;
|
||||
inline void Stop() override {
|
||||
Logger_.information("Stopping ");
|
||||
Logger().information("Stopping ");
|
||||
for( const auto & svr : RESTServers_ )
|
||||
svr->stop();
|
||||
Pool_.stopAll();
|
||||
@@ -2524,7 +2539,7 @@ namespace OpenWifi {
|
||||
|
||||
inline Poco::Net::HTTPRequestHandler *CallServer(const char *Path, uint64_t Id) {
|
||||
RESTAPIHandler::BindingMap Bindings;
|
||||
return RESTAPI_IntRouter(Path, Bindings, Logger_, Server_, Id);
|
||||
return RESTAPI_IntRouter(Path, Bindings, Logger(), Server_, Id);
|
||||
}
|
||||
private:
|
||||
std::vector<std::unique_ptr<Poco::Net::HTTPServer>> RESTServers_;
|
||||
@@ -2556,18 +2571,18 @@ namespace OpenWifi {
|
||||
};
|
||||
|
||||
inline int RESTAPI_IntServer::Start() {
|
||||
Logger_.information("Starting.");
|
||||
Logger().information("Starting.");
|
||||
Server_.InitLogging();
|
||||
|
||||
for(const auto & Svr: ConfigServersList_) {
|
||||
Logger_.information(Poco::format("Starting: %s:%s Keyfile:%s CertFile: %s", Svr.Address(), std::to_string(Svr.Port()),
|
||||
Logger().information(Poco::format("Starting: %s:%s Keyfile:%s CertFile: %s", Svr.Address(), std::to_string(Svr.Port()),
|
||||
Svr.KeyFile(),Svr.CertFile()));
|
||||
|
||||
auto Sock{Svr.CreateSecureSocket(Logger_)};
|
||||
auto Sock{Svr.CreateSecureSocket(Logger())};
|
||||
|
||||
Svr.LogCert(Logger_);
|
||||
Svr.LogCert(Logger());
|
||||
if(!Svr.RootCA().empty())
|
||||
Svr.LogCas(Logger_);
|
||||
Svr.LogCas(Logger());
|
||||
auto Params = new Poco::Net::HTTPServerParams;
|
||||
Params->setMaxThreads(50);
|
||||
Params->setMaxQueued(200);
|
||||
@@ -2640,6 +2655,16 @@ namespace OpenWifi {
|
||||
return ((RandomEngine_() % (max-min)) + min);
|
||||
}
|
||||
|
||||
inline Poco::Logger & GetLogger(const std::string &Name) {
|
||||
static auto initilized = false;
|
||||
|
||||
if(!initilized) {
|
||||
initilized = true;
|
||||
InitializeLoggingSystem();
|
||||
}
|
||||
return Poco::Logger::get(Name);
|
||||
}
|
||||
|
||||
inline void Exit(int Reason);
|
||||
inline void BusMessageReceived(const std::string &Key, const std::string & Message);
|
||||
inline MicroServiceMetaVec GetServices(const std::string & Type);
|
||||
@@ -2682,6 +2707,7 @@ namespace OpenWifi {
|
||||
inline static void SavePID();
|
||||
inline int main(const ArgVec &args) override;
|
||||
static MicroService & instance() { return *instance_; }
|
||||
inline void InitializeLoggingSystem();
|
||||
|
||||
private:
|
||||
static MicroService * instance_;
|
||||
@@ -2850,8 +2876,58 @@ namespace OpenWifi {
|
||||
|
||||
void MicroServicePostInitialization();
|
||||
|
||||
inline void MicroService::InitializeLoggingSystem() {
|
||||
static auto initialized = false;
|
||||
|
||||
if(!initialized) {
|
||||
initialized = true;
|
||||
LoadConfigurationFile();
|
||||
|
||||
auto LoggingDestination = MicroService::instance().ConfigGetString("logging.type", "file");
|
||||
auto LoggingFormat = MicroService::instance().ConfigGetString("logging.format",
|
||||
"%Y-%m-%d %H:%M:%S %s: [%p] %t");
|
||||
if (LoggingDestination == "console") {
|
||||
Poco::AutoPtr<Poco::ConsoleChannel> Console(new Poco::ConsoleChannel);
|
||||
Poco::AutoPtr<Poco::PatternFormatter> Formatter(new Poco::PatternFormatter);
|
||||
Formatter->setProperty("pattern", LoggingFormat);
|
||||
Poco::AutoPtr<Poco::FormattingChannel> FormattingChannel(
|
||||
new Poco::FormattingChannel(Formatter, Console));
|
||||
Poco::Logger::root().setChannel(FormattingChannel);
|
||||
} else if (LoggingDestination == "colorconsole") {
|
||||
Poco::AutoPtr<Poco::ColorConsoleChannel> Console(new Poco::ColorConsoleChannel);
|
||||
Poco::AutoPtr<Poco::PatternFormatter> Formatter(new Poco::PatternFormatter);
|
||||
Formatter->setProperty("pattern", LoggingFormat);
|
||||
Poco::AutoPtr<Poco::FormattingChannel> FormattingChannel(
|
||||
new Poco::FormattingChannel(Formatter, Console));
|
||||
Poco::Logger::root().setChannel(FormattingChannel);
|
||||
} else if (LoggingDestination == "sql") {
|
||||
|
||||
} else if (LoggingDestination == "syslog") {
|
||||
//"CREATE TABLE T_POCO_LOG (Source VARCHAR, Name VARCHAR, ProcessId INTEGER, Thread VARCHAR, ThreadId INTEGER, Priority INTEGER, Text VARCHAR, DateTime DATE)"
|
||||
} else {
|
||||
auto LoggingLocation =
|
||||
MicroService::instance().ConfigPath("logging.path", "$OWCERT_ROOT/logs") + "/log";
|
||||
|
||||
Poco::AutoPtr<Poco::FileChannel> FileChannel(new Poco::FileChannel);
|
||||
FileChannel->setProperty("rotation", "10 M");
|
||||
FileChannel->setProperty("archive", "timestamp");
|
||||
FileChannel->setProperty("path", LoggingLocation);
|
||||
Poco::AutoPtr<Poco::PatternFormatter> Formatter(new Poco::PatternFormatter);
|
||||
Formatter->setProperty("pattern", LoggingFormat);
|
||||
Poco::AutoPtr<Poco::FormattingChannel> FormattingChannel(
|
||||
new Poco::FormattingChannel(Formatter, FileChannel));
|
||||
Poco::Logger::root().setChannel(FormattingChannel);
|
||||
}
|
||||
auto Level = Poco::Logger::parseLevel(MicroService::instance().ConfigGetString("logging.level", "debug"));
|
||||
Poco::Logger::root().setLevel(Level);
|
||||
}
|
||||
}
|
||||
|
||||
inline void MicroService::initialize(Poco::Util::Application &self) {
|
||||
// add the default services
|
||||
LoadConfigurationFile();
|
||||
InitializeLoggingSystem();
|
||||
|
||||
SubSystems_.push_back(KafkaManager());
|
||||
SubSystems_.push_back(ALBHealthCheckServer());
|
||||
SubSystems_.push_back(RESTAPI_ExtServer());
|
||||
@@ -2863,17 +2939,6 @@ namespace OpenWifi {
|
||||
Poco::Net::FTPStreamFactory::registerFactory();
|
||||
Poco::Net::FTPSStreamFactory::registerFactory();
|
||||
|
||||
LoadConfigurationFile();
|
||||
|
||||
static const char * LogFilePathKey = "logging.channels.c2.path";
|
||||
|
||||
if(LogDir_.empty()) {
|
||||
std::string OriginalLogFileValue = ConfigPath(LogFilePathKey);
|
||||
config().setString(LogFilePathKey, OriginalLogFileValue);
|
||||
} else {
|
||||
config().setString(LogFilePathKey, LogDir_);
|
||||
}
|
||||
|
||||
Poco::File DataDir(ConfigPath("openwifi.system.data"));
|
||||
DataDir_ = DataDir.path();
|
||||
if(!DataDir.exists()) {
|
||||
@@ -3167,6 +3232,13 @@ namespace OpenWifi {
|
||||
}
|
||||
}
|
||||
|
||||
inline SubSystemServer::SubSystemServer(std::string Name, const std::string &LoggingPrefix,
|
||||
std::string SubSystemConfigPrefix):
|
||||
Name_(std::move(Name)),
|
||||
LoggerPrefix_(LoggingPrefix),
|
||||
SubSystemConfigPrefix_(std::move(SubSystemConfigPrefix)) {
|
||||
}
|
||||
|
||||
inline int MicroService::main(const ArgVec &args) {
|
||||
|
||||
MyErrorHandler ErrorHandler(*this);
|
||||
@@ -3174,6 +3246,7 @@ namespace OpenWifi {
|
||||
|
||||
if (!HelpRequested_) {
|
||||
SavePID();
|
||||
|
||||
Poco::Logger &logger = Poco::Logger::get(DAEMON_APP_NAME);
|
||||
logger.notice(Poco::format("Starting %s version %s.",DAEMON_APP_NAME, Version()));
|
||||
|
||||
@@ -3185,6 +3258,7 @@ namespace OpenWifi {
|
||||
if (config().getBool("application.runAsDaemon", false)) {
|
||||
logger.information("Starting as a daemon.");
|
||||
}
|
||||
|
||||
logger.information(Poco::format("System ID set to %Lu",ID_));
|
||||
StartSubSystemServers();
|
||||
waitForTerminationRequest();
|
||||
@@ -3212,10 +3286,11 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
inline void SubSystemServer::initialize(Poco::Util::Application &self) {
|
||||
Logger_.notice("Initializing...");
|
||||
auto i = 0;
|
||||
bool good = true;
|
||||
|
||||
Log_ = std::make_unique<LoggerWrapper>(Poco::Logger::get(LoggerPrefix_));
|
||||
|
||||
ConfigServersList_.clear();
|
||||
while (good) {
|
||||
std::string root{SubSystemConfigPrefix_ + ".host." + std::to_string(i) + "."};
|
||||
@@ -3272,7 +3347,7 @@ namespace OpenWifi {
|
||||
Port_ = (int)MicroService::instance().ConfigGetInt("alb.port",15015);
|
||||
Socket_ = std::make_unique<Poco::Net::ServerSocket>(Port_);
|
||||
auto Params = new Poco::Net::HTTPServerParams;
|
||||
Server_ = std::make_unique<Poco::Net::HTTPServer>(new ALBRequestHandlerFactory(Logger_), *Socket_, Params);
|
||||
Server_ = std::make_unique<Poco::Net::HTTPServer>(new ALBRequestHandlerFactory(Logger()), *Socket_, Params);
|
||||
Server_->start();
|
||||
}
|
||||
|
||||
@@ -3340,9 +3415,9 @@ namespace OpenWifi {
|
||||
if(Num)
|
||||
Producer.flush();
|
||||
} catch (const cppkafka::HandleException &E ) {
|
||||
KafkaManager()->Logger_.warning(Poco::format("Caught a Kafka exception (producer): %s",std::string{E.what()}));
|
||||
KafkaManager()->Logger().warning(Poco::format("Caught a Kafka exception (producer): %s",std::string{E.what()}));
|
||||
} catch (const Poco::Exception &E) {
|
||||
KafkaManager()->Logger_.log(E);
|
||||
KafkaManager()->Logger().log(E);
|
||||
}
|
||||
}
|
||||
Producer.flush();
|
||||
@@ -3368,13 +3443,13 @@ namespace OpenWifi {
|
||||
cppkafka::Consumer Consumer(Config);
|
||||
Consumer.set_assignment_callback([this](cppkafka::TopicPartitionList& partitions) {
|
||||
if(!partitions.empty()) {
|
||||
KafkaManager()->Logger_.information(Poco::format("Partition assigned: %Lu...",
|
||||
KafkaManager()->Logger().information(Poco::format("Partition assigned: %Lu...",
|
||||
(uint64_t)partitions.front().get_partition()));
|
||||
}
|
||||
});
|
||||
Consumer.set_revocation_callback([this](const cppkafka::TopicPartitionList& partitions) {
|
||||
if(!partitions.empty()) {
|
||||
KafkaManager()->Logger_.information(Poco::format("Partition revocation: %Lu...",
|
||||
KafkaManager()->Logger().information(Poco::format("Partition revocation: %Lu...",
|
||||
(uint64_t)partitions.front().get_partition()));
|
||||
}
|
||||
});
|
||||
@@ -3397,7 +3472,7 @@ namespace OpenWifi {
|
||||
continue;
|
||||
if (Msg.get_error()) {
|
||||
if (!Msg.is_eof()) {
|
||||
KafkaManager()->Logger_.error(Poco::format("Error: %s", Msg.get_error().to_string()));
|
||||
KafkaManager()->Logger().error(Poco::format("Error: %s", Msg.get_error().to_string()));
|
||||
}if(!AutoCommit)
|
||||
Consumer.async_commit(Msg);
|
||||
continue;
|
||||
@@ -3417,9 +3492,9 @@ namespace OpenWifi {
|
||||
Consumer.async_commit(Msg);
|
||||
}
|
||||
} catch (const cppkafka::HandleException &E) {
|
||||
KafkaManager()->Logger_.warning(Poco::format("Caught a Kafka exception (consumer): %s",std::string{E.what()}));
|
||||
KafkaManager()->Logger().warning(Poco::format("Caught a Kafka exception (consumer): %s",std::string{E.what()}));
|
||||
} catch (const Poco::Exception &E) {
|
||||
KafkaManager()->Logger_.log(E);
|
||||
KafkaManager()->Logger().log(E);
|
||||
}
|
||||
}
|
||||
Consumer.unsubscribe();
|
||||
@@ -3427,14 +3502,14 @@ namespace OpenWifi {
|
||||
|
||||
inline void RESTAPI_ExtServer::reinitialize(Poco::Util::Application &self) {
|
||||
MicroService::instance().LoadConfigurationFile();
|
||||
Logger_.information("Reinitializing.");
|
||||
Logger().information("Reinitializing.");
|
||||
Stop();
|
||||
Start();
|
||||
}
|
||||
|
||||
void RESTAPI_IntServer::reinitialize(Poco::Util::Application &self) {
|
||||
MicroService::instance().LoadConfigurationFile();
|
||||
Logger_.information("Reinitializing.");
|
||||
Logger().information("Reinitializing.");
|
||||
Stop();
|
||||
Start();
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace OpenWifi {
|
||||
int Start() override {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
|
||||
Logger_.setLevel(Poco::Message::PRIO_NOTICE);
|
||||
Logger_.notice("Starting.");
|
||||
Logger().setLevel(Poco::Message::PRIO_NOTICE);
|
||||
Logger().notice("Starting.");
|
||||
std::string DBType = MicroService::instance().ConfigGetString("storage.type");
|
||||
|
||||
if (DBType == "sqlite") {
|
||||
@@ -101,7 +101,7 @@ namespace OpenWifi {
|
||||
#else
|
||||
|
||||
inline int StorageClass::Setup_SQLite() {
|
||||
Logger_.notice("SQLite StorageClass enabled.");
|
||||
Logger().notice("SQLite StorageClass enabled.");
|
||||
dbType_ = sqlite;
|
||||
auto DBName = MicroService::instance().DataDir() + "/" + MicroService::instance().ConfigGetString("storage.type.sqlite.db");
|
||||
auto NumSessions = MicroService::instance().ConfigGetInt("storage.type.sqlite.maxsessions", 64);
|
||||
@@ -112,7 +112,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
inline int StorageClass::Setup_MySQL() {
|
||||
Logger_.notice("MySQL StorageClass enabled.");
|
||||
Logger().notice("MySQL StorageClass enabled.");
|
||||
dbType_ = mysql;
|
||||
auto NumSessions = MicroService::instance().ConfigGetInt("storage.type.mysql.maxsessions", 64);
|
||||
auto IdleTime = MicroService::instance().ConfigGetInt("storage.type.mysql.idletime", 60);
|
||||
@@ -137,7 +137,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
inline int StorageClass::Setup_PostgreSQL() {
|
||||
Logger_.notice("PostgreSQL StorageClass enabled.");
|
||||
Logger().notice("PostgreSQL StorageClass enabled.");
|
||||
dbType_ = pgsql;
|
||||
auto NumSessions = MicroService::instance().ConfigGetInt("storage.type.postgresql.maxsessions", 64);
|
||||
auto IdleTime = MicroService::instance().ConfigGetInt("storage.type.postgresql.idletime", 60);
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenWifi {
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end()) {
|
||||
EndPoints_[Id] = EndPoint{.Device = Conn };
|
||||
Logger_.information(Poco::format("Registering session: %s, device:'%s'",Id,It->second.SerialNumber));
|
||||
Logger().information(Poco::format("Registering session: %s, device:'%s'",Id,It->second.SerialNumber));
|
||||
} else {
|
||||
It->second.Device = Conn;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ namespace OpenWifi {
|
||||
return;
|
||||
if(It->second.Device!=Conn)
|
||||
return;
|
||||
Logger_.information(Poco::format("DeRegistering session: %s, device:'%s'",Id,It->second.SerialNumber));
|
||||
Logger().information(Poco::format("DeRegistering session: %s, device:'%s'",Id,It->second.SerialNumber));
|
||||
It->second.Device = nullptr;
|
||||
It->second.Done = true;
|
||||
It->second.DeviceConnected = 0 ;
|
||||
@@ -119,7 +119,7 @@ namespace OpenWifi {
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end())
|
||||
return;
|
||||
Logger_.information(Poco::format("User: %s, Serial: %s logged in.",It->second.UserName, It->second.SerialNumber ));
|
||||
Logger().information(Poco::format("User: %s, Serial: %s logged in.",It->second.UserName, It->second.SerialNumber ));
|
||||
}
|
||||
|
||||
inline bool ValidEndPoint(const std::string &Id, const std::string &Token) {
|
||||
@@ -171,7 +171,7 @@ namespace OpenWifi {
|
||||
|
||||
}
|
||||
|
||||
Poco::Logger & Logger() { return Logger_; }
|
||||
Poco::Logger & Logger() { return Logger(); }
|
||||
|
||||
bool Login(const std::string & Id_);
|
||||
bool Logout(const std::string & Id_);
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return true;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace OpenWifi {
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ namespace OpenWifi {
|
||||
BlackListDevices.erase(SerialNumber);
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ namespace OpenWifi {
|
||||
|
||||
return Select.rowsExtracted()==1;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ bool Storage::CreateDeviceCapabilities(std::string &SerialNumber, std::string &C
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ bool Storage::CreateDeviceCapabilities(std::string &SerialNumber, std::string &C
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ bool Storage::CreateDeviceCapabilities(std::string &SerialNumber, std::string &C
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ bool Storage::CreateDeviceCapabilities(std::string &SerialNumber, std::string &C
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ bool Storage::CreateDeviceCapabilities(std::string &SerialNumber, std::string &C
|
||||
}
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ typedef Poco::Tuple<
|
||||
return true;
|
||||
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ typedef Poco::Tuple<
|
||||
}
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ typedef Poco::Tuple<
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ typedef Poco::Tuple<
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ typedef Poco::Tuple<
|
||||
return true;
|
||||
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -305,7 +305,7 @@ typedef Poco::Tuple<
|
||||
Update.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -328,7 +328,7 @@ typedef Poco::Tuple<
|
||||
Select.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -345,7 +345,7 @@ typedef Poco::Tuple<
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -372,7 +372,7 @@ typedef Poco::Tuple<
|
||||
}
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -406,7 +406,7 @@ typedef Poco::Tuple<
|
||||
}
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -427,7 +427,7 @@ typedef Poco::Tuple<
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -478,7 +478,7 @@ typedef Poco::Tuple<
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -505,7 +505,7 @@ typedef Poco::Tuple<
|
||||
Update.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -561,10 +561,10 @@ typedef Poco::Tuple<
|
||||
|
||||
return true;
|
||||
} else {
|
||||
Logger_.warning(Poco::format("File %s is too large.", FileName.path()));
|
||||
Logger().warning(Poco::format("File %s is too large.", FileName.path()));
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -607,7 +607,7 @@ typedef Poco::Tuple<
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -626,7 +626,7 @@ typedef Poco::Tuple<
|
||||
return true;
|
||||
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -644,7 +644,7 @@ typedef Poco::Tuple<
|
||||
return true;
|
||||
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -660,7 +660,7 @@ typedef Poco::Tuple<
|
||||
Delete.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -684,7 +684,7 @@ typedef Poco::Tuple<
|
||||
}
|
||||
return true;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -90,12 +90,12 @@ namespace OpenWifi {
|
||||
Insert.execute();
|
||||
return true;
|
||||
} else {
|
||||
Logger_.warning("Cannot create device: invalid configuration.");
|
||||
Logger().warning("Cannot create device: invalid configuration.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ namespace OpenWifi {
|
||||
return false;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ namespace OpenWifi {
|
||||
return Select.rowsExtracted()==1;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -241,11 +241,11 @@ namespace OpenWifi {
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger_.information(Poco::format("AUTO-PROVISIONING: no default configuration for model:%s", Model));
|
||||
Logger().information(Poco::format("AUTO-PROVISIONING: no default configuration for model:%s", Model));
|
||||
return false;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ namespace OpenWifi {
|
||||
return Count;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return Count;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace OpenWifi {
|
||||
Select.execute();
|
||||
return true;
|
||||
} catch(const Poco::Exception & E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ namespace OpenWifi {
|
||||
Select.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E ) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ namespace OpenWifi {
|
||||
|
||||
Config::Config Cfg(Configuration);
|
||||
if (!Cfg.Valid()) {
|
||||
Logger_.warning(Poco::format("CONFIG-UPDATE(%s): Configuration was not valid", SerialNumber));
|
||||
Logger().warning(Poco::format("CONFIG-UPDATE(%s): Configuration was not valid", SerialNumber));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -190,14 +190,14 @@ namespace OpenWifi {
|
||||
Poco::Data::Keywords::use(R),
|
||||
Poco::Data::Keywords::use(SerialNumber);
|
||||
Update.execute();
|
||||
Logger_.information(Poco::format("DEVICE-CONFIGURATION-UPDATED(%s): New UUID is %Lu", SerialNumber, NewUUID));
|
||||
Logger().information(Poco::format("DEVICE-CONFIGURATION-UPDATED(%s): New UUID is %Lu", SerialNumber, NewUUID));
|
||||
Configuration = D.Configuration;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -244,17 +244,17 @@ namespace OpenWifi {
|
||||
SerialNumberCache()->AddSerialNumber(DeviceDetails.SerialNumber);
|
||||
return true;
|
||||
} else {
|
||||
Logger_.warning("Cannot create device: invalid configuration.");
|
||||
Logger().warning("Cannot create device: invalid configuration.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Logger_.warning(Poco::format("Device %s already exists.", SerialNumber));
|
||||
Logger().warning(Poco::format("Device %s already exists.", SerialNumber));
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -280,7 +280,7 @@ namespace OpenWifi {
|
||||
bool Storage::CreateDefaultDevice(std::string &SerialNumber, std::string &Capabilities, std::string & Firmware, std::string &Compat, const Poco::Net::IPAddress & IPAddress) {
|
||||
GWObjects::Device D;
|
||||
|
||||
Logger_.information(Poco::format("AUTO-CREATION(%s)", SerialNumber));
|
||||
Logger().information(Poco::format("AUTO-CREATION(%s)", SerialNumber));
|
||||
uint64_t Now = time(nullptr);
|
||||
|
||||
Config::Capabilities Caps(Capabilities);
|
||||
@@ -329,7 +329,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -348,7 +348,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -366,7 +366,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -384,7 +384,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -402,7 +402,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -435,7 +435,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -473,7 +473,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -500,7 +500,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -525,7 +525,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -546,7 +546,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -572,7 +572,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -596,7 +596,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -635,7 +635,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -654,7 +654,7 @@ namespace OpenWifi {
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -677,7 +677,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return true;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -814,7 +814,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return true;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ namespace OpenWifi {
|
||||
Delete.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace OpenWifi {
|
||||
return !Stats.empty();
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ namespace OpenWifi {
|
||||
Delete.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenWifi {
|
||||
Poco::Data::Statement Insert(Sess);
|
||||
|
||||
uint64_t Now = time(nullptr);
|
||||
Logger_.information("Device:" + Stats.SerialNumber + " Stats size:" + std::to_string(Stats.Data.size()));
|
||||
Logger().information("Device:" + Stats.SerialNumber + " Stats size:" + std::to_string(Stats.Data.size()));
|
||||
std::string St{"INSERT INTO Statistics ( " +
|
||||
DB_StatsSelectFields +
|
||||
" ) VALUES ( " +
|
||||
@@ -55,7 +55,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ bool Storage::DeleteStatisticsData(std::string &SerialNumber, uint64_t FromDate,
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ bool Storage::DeleteStatisticsData(std::string &SerialNumber, uint64_t FromDate,
|
||||
Delete.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return 0;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return 0;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace OpenWifi {
|
||||
|
||||
return 0;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return 0;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ namespace OpenWifi {
|
||||
|
||||
return 0;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return 0;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return 0;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return 0;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -320,7 +320,7 @@ namespace OpenWifi {
|
||||
|
||||
return 0;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ namespace OpenWifi {
|
||||
return 0;
|
||||
}
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
Logger().log(E);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user