Silence expected error logs
Summary: When an app with sonar is run for the first time, the necessary files don't exist. This is expected, so don't output an error, only error if they do exist but there's some other problem. Reviewed By: emilsjolander Differential Revision: D8350995 fbshipit-source-id: ff0a4f0e7a73848f6172c6108a0caee6efb43553
This commit is contained in:
committed by
Facebook Github Bot
parent
8af2af6558
commit
4fbe638adf
@@ -42,6 +42,8 @@ static constexpr int insecurePort = 8089;
|
|||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace sonar {
|
namespace sonar {
|
||||||
|
|
||||||
|
bool fileExists(std::string fileName);
|
||||||
|
|
||||||
class ConnectionEvents : public rsocket::RSocketConnectionEvents {
|
class ConnectionEvents : public rsocket::RSocketConnectionEvents {
|
||||||
private:
|
private:
|
||||||
SonarWebSocketImpl* websocket_;
|
SonarWebSocketImpl* websocket_;
|
||||||
@@ -249,6 +251,9 @@ void SonarWebSocketImpl::requestSignedCertFromSonar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string SonarWebSocketImpl::loadStringFromFile(std::string fileName) {
|
std::string SonarWebSocketImpl::loadStringFromFile(std::string fileName) {
|
||||||
|
if (!fileExists(fileName)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
std::stringstream buffer;
|
std::stringstream buffer;
|
||||||
std::ifstream stream;
|
std::ifstream stream;
|
||||||
std::string line;
|
std::string line;
|
||||||
@@ -283,5 +288,10 @@ bool SonarWebSocketImpl::ensureSonarDirExists() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fileExists(std::string fileName) {
|
||||||
|
struct stat buffer;
|
||||||
|
return stat(fileName.c_str(), &buffer) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace sonar
|
} // namespace sonar
|
||||||
} // namespace facebook
|
} // namespace facebook
|
||||||
|
|||||||
Reference in New Issue
Block a user