Skip to content

Commit

Permalink
add telemetry server and remove some logs (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterTea authored Jan 22, 2021
1 parent 27de07a commit 35da524
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/base/TcpSocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int TcpSocketHandler::connect(const SocketEndpoint &endpoint) {
LOG(INFO) << "Connected to server: " << p->ai_canonname
<< " using fd " << sockFd;
} else {
STERROR << "Connected to server but canonname is null somehow";
LOG(INFO) << "Connected to server but canonname is null somehow";
}
// Make sure that socket becomes blocking once it's attached to a
// server.
Expand Down Expand Up @@ -196,9 +196,9 @@ set<int> TcpSocketHandler::listen(const SocketEndpoint &endpoint) {
if (::bind(sockFd, p->ai_addr, p->ai_addrlen) == -1) {
// This most often happens because the port is in use.
auto localErrno = errno;
STERROR << "Error binding " << p->ai_family << "/" << p->ai_socktype
<< "/" << p->ai_protocol << ": " << localErrno << " "
<< strerror(localErrno);
LOG(ERROR) << "Error binding " << p->ai_family << "/" << p->ai_socktype
<< "/" << p->ai_protocol << ": " << localErrno << " "
<< strerror(localErrno);
CLOG(INFO, "stdout") << "Error binding " << p->ai_family << "/"
<< p->ai_socktype << "/" << p->ai_protocol << ": "
<< localErrno << " " << strerror(localErrno) << endl;
Expand Down
17 changes: 16 additions & 1 deletion src/terminal/TerminalServerMain.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "TelemetryService.hpp"
#include "TerminalServer.hpp"

using namespace et;
Expand Down Expand Up @@ -34,6 +35,9 @@ int main(int argc, char **argv) {
("serverfifo",
"If set, listens on the matching fifo name", //
cxxopts::value<std::string>()->default_value(ROUTER_FIFO_NAME)) //
("telemetry",
"Allow et to anonymously send errors to guide future improvements",
cxxopts::value<bool>()) //
;

auto result = options.parse(argc, argv);
Expand Down Expand Up @@ -67,6 +71,7 @@ int main(int argc, char **argv) {
string maxlogsize = "20971520";

int port = 0;
bool telemetry = true;
if (result.count("cfgfile")) {
// Load the config file
CSimpleIniA ini(true, true, true);
Expand All @@ -79,6 +84,8 @@ int main(int argc, char **argv) {
port = stoi(portString);
}
}

telemetry = bool(stoi(ini.GetValue("Debug", "Telemetry", "1")));
// read verbose level (prioritize command line option over cfgfile)
const char *vlevel = ini.GetValue("Debug", "verbose", NULL);
if (result.count("verbose")) {
Expand Down Expand Up @@ -121,6 +128,10 @@ int main(int argc, char **argv) {
port = result["port"].as<int>();
}

if (result.count("telemetry")) {
telemetry = result["telemetry"].as<bool>();
}

GOOGLE_PROTOBUF_VERIFY_VERSION;
srand(1);

Expand All @@ -129,7 +140,8 @@ int main(int argc, char **argv) {
}

// Set log file for etserver process here.
LogHandler::setupLogFile(&defaultConf, GetTempDirectory() + "etserver-%datetime.log",
LogHandler::setupLogFile(&defaultConf,
GetTempDirectory() + "etserver-%datetime.log",
maxlogsize);
// Reconfigure default logger to apply settings above
el::Loggers::reconfigureLogger("default", defaultConf);
Expand All @@ -138,6 +150,9 @@ int main(int argc, char **argv) {
// Install log rotation callback
el::Helpers::installPreRollOutCallback(LogHandler::rolloutHandler);

TelemetryService::create(
telemetry, GetTempDirectory() + "/.sentry-native-etserver", "Server");

std::shared_ptr<SocketHandler> tcpSocketHandler(new TcpSocketHandler());
std::shared_ptr<PipeSocketHandler> pipeSocketHandler(
new PipeSocketHandler());
Expand Down

0 comments on commit 35da524

Please sign in to comment.