=== modified file 'log.cc'
@@ -24,7 +24,7 @@
using std::string;
const string Log::continuation_prefix("\x10");
-string Log::appname;
+string Log::appname_;
bool Log::do_debug_(false);
#ifndef ANDROID
@@ -146,7 +146,7 @@
{
va_list ap;
va_start(ap, fmt);
- __android_log_vprint(ANDROID_LOG_INFO, appname.c_str(), fmt, ap);
+ __android_log_vprint(ANDROID_LOG_INFO, appname_.c_str(), fmt, ap);
va_end(ap);
}
@@ -157,7 +157,7 @@
return;
va_list ap;
va_start(ap, fmt);
- __android_log_vprint(ANDROID_LOG_DEBUG, appname.c_str(), fmt, ap);
+ __android_log_vprint(ANDROID_LOG_DEBUG, appname_.c_str(), fmt, ap);
va_end(ap);
}
@@ -166,7 +166,7 @@
{
va_list ap;
va_start(ap, fmt);
- __android_log_vprint(ANDROID_LOG_ERROR, appname.c_str(), fmt, ap);
+ __android_log_vprint(ANDROID_LOG_ERROR, appname_.c_str(), fmt, ap);
va_end(ap);
}
=== modified file 'log.h'
@@ -18,7 +18,11 @@
class Log
{
public:
- static void init(bool do_debug = false) { do_debug_ = do_debug; }
+ static void init(const std::string& appname, bool do_debug = false)
+ {
+ appname_ = appname;
+ do_debug_ = do_debug;
+ }
// Emit an informational message
static void info(const char *fmt, ...);
// Emit a debugging message
@@ -31,10 +35,11 @@
// message is a continuation of a previous log message to be put on the
// same line.
static const std::string continuation_prefix;
+private:
// A constant for identifying the log messages as originating from a
// particular application.
- static std::string appname;
-private:
+ static std::string appname_;
+ // Indicates whether debug level messages should generate any output
static bool do_debug_;
};