Bug 1352538: allow tests to set connector level. r?=bwc
MozReview-Commit-ID: 5hQfWDeBrnd
--- a/media/mtransport/rlogconnector.cpp
+++ b/media/mtransport/rlogconnector.cpp
@@ -64,32 +64,39 @@ MOZ_MTLOG_MODULE("nicer");
namespace mozilla {
RLogConnector* RLogConnector::instance;
RLogConnector::RLogConnector()
: log_limit_(4096),
mutex_("RLogConnector::mutex_"),
- disableCount_(0) {
+ disableCount_(0),
+ max_connector_log_level_(LOG_INFO) {
}
RLogConnector::~RLogConnector() {
}
void RLogConnector::SetLogLimit(uint32_t new_limit) {
OffTheBooksMutexAutoLock lock(mutex_);
log_limit_ = new_limit;
RemoveOld();
}
+void RLogConnector::SetConnectorLogLevel(int new_level) {
+ if ((new_level >= LOG_EMERG) && (new_level <= LOG_DEBUG)) {
+ max_connector_log_level_ = new_level;
+ }
+}
+
void RLogConnector::Log(int level, std::string&& log) {
MOZ_MTLOG(rLogLvlToMozLogLvl(level), log);
- if (level <= LOG_INFO) {
+ if (level <= max_connector_log_level_) {
OffTheBooksMutexAutoLock lock(mutex_);
if (disableCount_ == 0) {
AddMsg(Move(log));
}
}
}
void RLogConnector::AddMsg(std::string&& msg) {
--- a/media/mtransport/rlogconnector.h
+++ b/media/mtransport/rlogconnector.h
@@ -90,16 +90,17 @@ class RLogConnector {
std::deque<std::string>* matching_logs);
inline void GetAny(uint32_t limit,
std::deque<std::string>* matching_logs) {
Filter("", limit, matching_logs);
}
void SetLogLimit(uint32_t new_limit);
+ void SetConnectorLogLevel(int new_level);
void Log(int level, std::string&& log);
void Clear();
// Methods to signal when a PeerConnection exists in a Private Window.
void EnterPrivateMode();
void ExitPrivateMode();
private:
@@ -116,14 +117,16 @@ class RLogConnector {
* happening/the ringbuffer is not being used.
*/
std::deque<std::string> log_messages_;
/* Max size of log buffer (should we use time-depth instead/also?) */
uint32_t log_limit_;
OffTheBooksMutex mutex_;
uint32_t disableCount_;
+ int max_connector_log_level_;
+
DISALLOW_COPY_ASSIGN(RLogConnector);
}; // class RLogConnector
} // namespace mozilla
#endif // rlogconnector_h__
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -2280,16 +2280,19 @@ TEST_F(WebRtcIceGatherTest, TestGatherDN
peer_->SetStunServer(stun_server_hostname_, kDefaultStunServerPort);
peer_->SetDNSResolver();
Gather();
ASSERT_TRUE(StreamHasMatchingCandidate(0, " UDP "));
ASSERT_TRUE(StreamHasMatchingCandidate(0, "typ srflx raddr"));
}
TEST_F(WebRtcIceGatherTest, TestGatherDNSStunServerHostnameTcp) {
+ // Run with higher log level until we fix bug 1352538
+ RLogConnector::GetInstance()->SetConnectorLogLevel(LOG_DEBUG);
+
EnsurePeer(ICE_TEST_PEER_OFFERER | ICE_TEST_PEER_ENABLED_TCP);
peer_->SetStunServer(stun_server_hostname_, kDefaultStunServerPort,
kNrIceTransportTcp);
peer_->SetDNSResolver();
Gather();
ASSERT_TRUE(StreamHasMatchingCandidate(0, "tcptype passive"));
ASSERT_FALSE(StreamHasMatchingCandidate(0, "tcptype passive", " 9 "));
ASSERT_TRUE(StreamHasMatchingCandidate(0, "tcptype so"));