diff --git a/services/lib/src/GlobalTools.h b/services/lib/src/GlobalTools.h --- a/services/lib/src/GlobalTools.h +++ b/services/lib/src/GlobalTools.h @@ -21,6 +21,8 @@ bool validateUUIDv4(const std::string &uuid); +void InitLogging(const std::string &programName); + } // namespace tools } // namespace network } // namespace comm diff --git a/services/lib/src/GlobalTools.cpp b/services/lib/src/GlobalTools.cpp --- a/services/lib/src/GlobalTools.cpp +++ b/services/lib/src/GlobalTools.cpp @@ -57,6 +57,18 @@ } } +void InitLogging(const std::string &programName) { + FLAGS_logtostderr = true; + FLAGS_colorlogtostderr = true; + if (comm::network::tools::isSandbox()) { + // Log levels INFO, WARNING, ERROR, FATAL are 0, 1, 2, 3, respectively + FLAGS_minloglevel = 0; + } else { + FLAGS_minloglevel = 1; + } + google::InitGoogleLogging(programName.c_str()); +} + } // namespace tools } // namespace network } // namespace comm diff --git a/services/tunnelbroker/src/server.cpp b/services/tunnelbroker/src/server.cpp --- a/services/tunnelbroker/src/server.cpp +++ b/services/tunnelbroker/src/server.cpp @@ -4,7 +4,6 @@ #include "GlobalTools.h" #include "TunnelbrokerServiceImpl.h" -#include #include #include @@ -35,23 +34,11 @@ AmqpManager::getInstance().connect(); } -void InitLogging(const char *programName) { - FLAGS_logtostderr = true; - FLAGS_colorlogtostderr = true; - if (comm::network::tools::isSandbox()) { - // Log levels INFO, WARNING, ERROR, FATAL are 0, 1, 2, 3, respectively - FLAGS_minloglevel = 0; - } else { - FLAGS_minloglevel = 1; - } - google::InitGoogleLogging(programName); -} - } // namespace network } // namespace comm int main(int argc, char **argv) { - comm::network::InitLogging(argv[0]); + comm::network::tools::InitLogging("tunnelbroker"); if (comm::network::tools::isSandbox()) { comm::network::config::ConfigManager::getInstance().load( comm::network::DEV_CONFIG_FILE_PATH);