Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: webrtc/base/logging.cc

Issue 1338033003: Log to webrtc logging stream from java code. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: not lose tag Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« talk/app/webrtc/java/src/org/webrtc/Logging.java ('K') | « webrtc/base/logging.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/logging.cc
diff --git a/webrtc/base/logging.cc b/webrtc/base/logging.cc
index e2ee1150638f1afa6c18ded8d8dfc6050de666a8..52a8a14fdba6c0c685f4726b9259e895677e2539 100644
--- a/webrtc/base/logging.cc
+++ b/webrtc/base/logging.cc
@@ -114,6 +114,7 @@ bool LogMessage::thread_, LogMessage::timestamp_;
LogMessage::LogMessage(const char* file, int line, LoggingSeverity sev,
LogErrorContext err_ctx, int err, const char* module)
: severity_(sev),
+ android_tag_(kLibjingle),
AlexG 2015/09/14 20:12:33 kLibjingle is defined for WEBRTC_ANDROID only - th
jiayl2 2015/09/14 20:54:38 Done.
warn_slow_logs_delay_(WARN_SLOW_LOGS_DELAY) {
if (timestamp_) {
uint32 time = TimeSince(LogStartTime());
@@ -175,6 +176,14 @@ LogMessage::LogMessage(const char* file, int line, LoggingSeverity sev,
}
}
+LogMessage::LogMessage(const char* file,
+ int line,
+ LoggingSeverity sev,
+ const std::string& tag)
+ : LogMessage(file, line, sev, ERRCTX_NONE, 0 /* err */, NULL /* module */) {
+ android_tag_ = tag;
AlexG 2015/09/14 20:12:33 Move this to ctor initialization list?
jiayl2 2015/09/14 20:54:38 That will cause compile error
+}
+
LogMessage::~LogMessage() {
if (!extra_.empty())
print_stream_ << " : " << extra_;
@@ -182,7 +191,7 @@ LogMessage::~LogMessage() {
const std::string& str = print_stream_.str();
if (severity_ >= dbg_sev_) {
- OutputToDebug(str, severity_);
+ OutputToDebug(str, severity_, android_tag_);
}
uint32 before = Time();
@@ -333,7 +342,8 @@ void LogMessage::UpdateMinLogSeverity() EXCLUSIVE_LOCKS_REQUIRED(crit_) {
}
void LogMessage::OutputToDebug(const std::string& str,
- LoggingSeverity severity) {
+ LoggingSeverity severity,
+ const std::string& tag) {
bool log_to_stderr = log_to_stderr_;
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) && (!defined(DEBUG) || defined(NDEBUG))
// On the Mac, all stderr output goes to the Console log and causes clutter.
@@ -377,7 +387,7 @@ void LogMessage::OutputToDebug(const std::string& str,
int prio;
switch (severity) {
case LS_SENSITIVE:
- __android_log_write(ANDROID_LOG_INFO, kLibjingle, "SENSITIVE");
+ __android_log_write(ANDROID_LOG_INFO, tag.c_str(), "SENSITIVE");
if (log_to_stderr) {
fprintf(stderr, "SENSITIVE");
fflush(stderr);
@@ -404,13 +414,13 @@ void LogMessage::OutputToDebug(const std::string& str,
int idx = 0;
const int max_lines = size / kMaxLogLineSize + 1;
if (max_lines == 1) {
- __android_log_print(prio, kLibjingle, "%.*s", size, str.c_str());
+ __android_log_print(prio, tag.c_str(), "%.*s", size, str.c_str());
} else {
while (size > 0) {
const int len = std::min(size, kMaxLogLineSize);
// Use the size of the string in the format (str may have \0 in the
// middle).
- __android_log_print(prio, kLibjingle, "[%d/%d] %.*s",
+ __android_log_print(prio, tag.c_str(), "[%d/%d] %.*s",
line + 1, max_lines,
len, str.c_str() + idx);
idx += len;
« talk/app/webrtc/java/src/org/webrtc/Logging.java ('K') | « webrtc/base/logging.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698