From: Maxim Mamontov Date: Thu, 14 Apr 2016 18:29:08 +0000 (+0300) Subject: Some minor improvements on ticket26. X-Git-Tag: 2.409~174^2 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/d0175e4206e5856ddec364135b265a13ded8ce29?ds=inline;hp=-c Some minor improvements on ticket26. --- d0175e4206e5856ddec364135b265a13ded8ce29 diff --git a/projects/stargazer/main.cpp b/projects/stargazer/main.cpp index 26bd9727..702bfb86 100644 --- a/projects/stargazer/main.cpp +++ b/projects/stargazer/main.cpp @@ -349,6 +349,7 @@ while (running) WriteServLog("ReadSettings error. %s", newSettings.GetStrError().c_str()); else settings = newSettings; + WriteServLog.SetLogFileName(settings.GetLogFileName()); traffCnt.Reload(); manager.reload(settings); } diff --git a/projects/stargazer/plugins/authorization/ao/ao.h b/projects/stargazer/plugins/authorization/ao/ao.h index 34c15d91..9ed7ffcf 100644 --- a/projects/stargazer/plugins/authorization/ao/ao.h +++ b/projects/stargazer/plugins/authorization/ao/ao.h @@ -89,7 +89,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning() { return isRunning; } void SetSettings(const MODULE_SETTINGS &) {} int ParseSettings() { return 0; } diff --git a/projects/stargazer/plugins/authorization/stress/stress.h b/projects/stargazer/plugins/authorization/stress/stress.h index 8ab8122a..6ead8f33 100644 --- a/projects/stargazer/plugins/authorization/stress/stress.h +++ b/projects/stargazer/plugins/authorization/stress/stress.h @@ -93,7 +93,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning(); void SetSettings(const MODULE_SETTINGS & s); int ParseSettings(); diff --git a/projects/stargazer/plugins/capture/cap_debug/debug_cap.h b/projects/stargazer/plugins/capture/cap_debug/debug_cap.h index c9a629c6..8b1ccb92 100644 --- a/projects/stargazer/plugins/capture/cap_debug/debug_cap.h +++ b/projects/stargazer/plugins/capture/cap_debug/debug_cap.h @@ -69,7 +69,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } int ParseSettings() { return 0; } bool IsRunning(); const std::string & GetStrError() const; diff --git a/projects/stargazer/plugins/capture/cap_nf/cap_nf.h b/projects/stargazer/plugins/capture/cap_nf/cap_nf.h index ae0b3763..7d24403b 100644 --- a/projects/stargazer/plugins/capture/cap_nf/cap_nf.h +++ b/projects/stargazer/plugins/capture/cap_nf/cap_nf.h @@ -99,7 +99,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning() { return runningTCP || runningUDP; } const std::string & GetStrError() const { return errorStr; } std::string GetVersion() const { return VERSION; } diff --git a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h index 3c52701d..d8f4d6f8 100644 --- a/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h +++ b/projects/stargazer/plugins/capture/divert_freebsd/divert_cap.h @@ -51,7 +51,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning() { return isRunning; } void SetSettings(const MODULE_SETTINGS & s) { settings = s; } diff --git a/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.h b/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.h index 2a9840ae..b9150b8d 100644 --- a/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.h +++ b/projects/stargazer/plugins/capture/ether_freebsd/ether_cap.h @@ -98,7 +98,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning() { return isRunning; } void SetSettings(const MODULE_SETTINGS & s) { settings = s; } diff --git a/projects/stargazer/plugins/capture/ether_linux/ether_cap.h b/projects/stargazer/plugins/capture/ether_linux/ether_cap.h index 73455658..5bb938fe 100644 --- a/projects/stargazer/plugins/capture/ether_linux/ether_cap.h +++ b/projects/stargazer/plugins/capture/ether_linux/ether_cap.h @@ -52,7 +52,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning() { return isRunning; } int ParseSettings() { return 0; } diff --git a/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.h b/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.h index 7144d177..b7f76b05 100644 --- a/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.h +++ b/projects/stargazer/plugins/capture/ipq_linux/ipq_cap.h @@ -47,7 +47,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning() { return isRunning; } int ParseSettings() { return 0; } diff --git a/projects/stargazer/plugins/capture/nfqueue/nfqueue.h b/projects/stargazer/plugins/capture/nfqueue/nfqueue.h index 60829626..27198073 100644 --- a/projects/stargazer/plugins/capture/nfqueue/nfqueue.h +++ b/projects/stargazer/plugins/capture/nfqueue/nfqueue.h @@ -51,7 +51,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning() { return isRunning; } void SetSettings(const MODULE_SETTINGS & s) { settings = s; } diff --git a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h index 593f346d..ce295818 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h +++ b/projects/stargazer/plugins/configuration/rpcconfig/rpcconfig.h @@ -70,7 +70,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning() { return running && !stopped; } const std::string & GetStrError() const { return errorStr; } diff --git a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.h b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.h index 87756b4a..d1fbf24c 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/stgconfig.h +++ b/projects/stargazer/plugins/configuration/sgconfig/stgconfig.h @@ -60,7 +60,7 @@ class STG_CONFIG : public PLUGIN int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning() { return isRunning; } const std::string & GetStrError() const { return errorStr; } diff --git a/projects/stargazer/plugins/other/ping/ping.h b/projects/stargazer/plugins/other/ping/ping.h index 1a7e1b97..cfab1e55 100644 --- a/projects/stargazer/plugins/other/ping/ping.h +++ b/projects/stargazer/plugins/other/ping/ping.h @@ -112,7 +112,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning(); const std::string & GetStrError() const { return errorStr; } diff --git a/projects/stargazer/plugins/other/radius/radius.h b/projects/stargazer/plugins/other/radius/radius.h index 77dde0d5..0f1c95fc 100644 --- a/projects/stargazer/plugins/other/radius/radius.h +++ b/projects/stargazer/plugins/other/radius/radius.h @@ -98,7 +98,7 @@ public: int Start(); int Stop(); - int Reload(const MODULE_SETTINGS & ms) { return 0; } + int Reload(const MODULE_SETTINGS & /*ms*/) { return 0; } bool IsRunning() { return isRunning; } const std::string & GetStrError() const { return errorStr; } diff --git a/projects/stargazer/plugins/other/rscript/rscript.cpp b/projects/stargazer/plugins/other/rscript/rscript.cpp index 74bf87a1..4433dafd 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.cpp +++ b/projects/stargazer/plugins/other/rscript/rscript.cpp @@ -296,7 +296,7 @@ if (isRunning) return 0; } //----------------------------------------------------------------------------- -int REMOTE_SCRIPT::Reload(const MODULE_SETTINGS & ms) +int REMOTE_SCRIPT::Reload(const MODULE_SETTINGS & /*ms*/) { NRMapParser nrMapParser; diff --git a/projects/stargazer/plugins/other/smux/smux.cpp b/projects/stargazer/plugins/other/smux/smux.cpp index 5a20d495..4586807c 100644 --- a/projects/stargazer/plugins/other/smux/smux.cpp +++ b/projects/stargazer/plugins/other/smux/smux.cpp @@ -269,7 +269,7 @@ printfd(__FILE__, "SMUX::Stop() - After\n"); return 0; } -int SMUX::Reload(const MODULE_SETTINGS & ms) +int SMUX::Reload(const MODULE_SETTINGS & /*ms*/) { if (Stop()) return -1; diff --git a/stglibs/logger.lib/include/stg/logger.h b/stglibs/logger.lib/include/stg/logger.h index 115d1fb3..e8d625a0 100644 --- a/stglibs/logger.lib/include/stg/logger.h +++ b/stglibs/logger.lib/include/stg/logger.h @@ -44,18 +44,19 @@ private: mutable pthread_mutex_t mutex; }; //----------------------------------------------------------------------------- -class PLUGIN_LOGGER : private STG_LOGGER +class PLUGIN_LOGGER { -friend PLUGIN_LOGGER GetPluginLogger(const STG_LOGGER & logger, const std::string & pluginName); +friend PLUGIN_LOGGER GetPluginLogger(const STG_LOGGER& logger, const std::string& pluginName); public: - PLUGIN_LOGGER(const PLUGIN_LOGGER & rhs); - void operator()(const char * fmt, ...) const; - void operator()(const std::string & line) const; + PLUGIN_LOGGER(const PLUGIN_LOGGER& rhs) : m_parent(rhs.m_parent), m_pluginName(rhs.m_pluginName) {} + void operator()(const char* fmt, ...) const; + void operator()(const std::string& line) const; private: PLUGIN_LOGGER(const STG_LOGGER & logger, const std::string & pn); - std::string pluginName; + const STG_LOGGER& m_parent; + std::string m_pluginName; }; PLUGIN_LOGGER GetPluginLogger(const STG_LOGGER & logger, const std::string & pluginName); diff --git a/stglibs/logger.lib/logger.cpp b/stglibs/logger.lib/logger.cpp index 6289618e..4a455257 100644 --- a/stglibs/logger.lib/logger.cpp +++ b/stglibs/logger.lib/logger.cpp @@ -97,18 +97,10 @@ else } } //----------------------------------------------------------------------------- -PLUGIN_LOGGER::PLUGIN_LOGGER(const STG_LOGGER & logger, const std::string & pn) - : STG_LOGGER(), - pluginName(pn) +PLUGIN_LOGGER::PLUGIN_LOGGER(const STG_LOGGER& logger, const std::string& pn) + : m_parent(logger), + m_pluginName(pn) { - SetLogFileName(logger.fileName); -} -//----------------------------------------------------------------------------- -PLUGIN_LOGGER::PLUGIN_LOGGER(const PLUGIN_LOGGER & rhs) - : STG_LOGGER(), - pluginName(rhs.pluginName) -{ - SetLogFileName(fileName); } //----------------------------------------------------------------------------- void PLUGIN_LOGGER::operator()(const char * fmt, ...) const @@ -120,12 +112,12 @@ va_start(vl, fmt); vsnprintf(buff, sizeof(buff), fmt, vl); va_end(vl); -STG_LOGGER::operator()("[%s] %s", pluginName.c_str(), buff); +m_parent("[%s] %s", m_pluginName.c_str(), buff); } //----------------------------------------------------------------------------- void PLUGIN_LOGGER::operator()(const std::string & line) const { -STG_LOGGER::operator()("[%s] %s", pluginName.c_str(), line.c_str()); +m_parent("[%s] %s", m_pluginName.c_str(), line.c_str()); } //----------------------------------------------------------------------------- PLUGIN_LOGGER GetPluginLogger(const STG_LOGGER & logger, const std::string & pluginName)