|
@@ -108,11 +108,17 @@ string VersionString(int version) {
|
|
// ===================================================================
|
|
// ===================================================================
|
|
// emulates google3/base/logging.cc
|
|
// emulates google3/base/logging.cc
|
|
|
|
|
|
|
|
+// If the minimum logging level is not set, we default to logging messages for
|
|
|
|
+// all levels.
|
|
|
|
+#ifndef GOOGLE_PROTOBUF_MIN_LOG_LEVEL
|
|
|
|
+#define GOOGLE_PROTOBUF_MIN_LOG_LEVEL LOGLEVEL_INFO
|
|
|
|
+#endif
|
|
|
|
+
|
|
namespace internal {
|
|
namespace internal {
|
|
|
|
+
|
|
#if defined(__ANDROID__)
|
|
#if defined(__ANDROID__)
|
|
inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
|
|
inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
|
|
const string& message) {
|
|
const string& message) {
|
|
-#ifdef GOOGLE_PROTOBUF_MIN_LOG_LEVEL
|
|
|
|
if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
|
|
if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -143,11 +149,14 @@ inline void DefaultLogHandler(LogLevel level, const char* filename, int line,
|
|
__android_log_write(ANDROID_LOG_FATAL, "libprotobuf-native",
|
|
__android_log_write(ANDROID_LOG_FATAL, "libprotobuf-native",
|
|
"terminating.\n");
|
|
"terminating.\n");
|
|
}
|
|
}
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
#else
|
|
#else
|
|
void DefaultLogHandler(LogLevel level, const char* filename, int line,
|
|
void DefaultLogHandler(LogLevel level, const char* filename, int line,
|
|
const string& message) {
|
|
const string& message) {
|
|
|
|
+ if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" };
|
|
static const char* level_names[] = { "INFO", "WARNING", "ERROR", "FATAL" };
|
|
|
|
|
|
// We use fprintf() instead of cerr because we want this to work at static
|
|
// We use fprintf() instead of cerr because we want this to work at static
|