[Branch,~jesse-barker/libmatrix/trunk] Rev 35: Make appname a required parameter to Log::init and make it private as nothing public needs direct...

Message ID 20120127220112.30014.64360.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Jesse Barker Jan. 27, 2012, 10:01 p.m.
------------------------------------------------------------
revno: 35
committer: Jesse Barker <jesse.barker@linaro.org>
branch nick: trunk
timestamp: Fri 2012-01-27 13:40:46 -0800
message:
  Make appname a required parameter to Log::init and make it private as nothing public needs direct access
modified:
  log.cc
  log.h


--
lp:libmatrix
https://code.launchpad.net/~jesse-barker/libmatrix/trunk

You are subscribed to branch lp:libmatrix.
To unsubscribe from this branch go to https://code.launchpad.net/~jesse-barker/libmatrix/trunk/+edit-subscription

Patch

=== modified file 'log.cc'
--- log.cc	2012-01-27 11:55:16 +0000
+++ log.cc	2012-01-27 21:40:46 +0000
@@ -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'
--- log.h	2012-01-26 19:41:29 +0000
+++ log.h	2012-01-27 21:40:46 +0000
@@ -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_;
 };