diff mbox

[Branch,~jesse-barker/libmatrix/trunk] Rev 32: Only emit the colon character if the prefix is non-empty.

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

Commit Message

Jesse Barker Jan. 26, 2012, 5:34 p.m. UTC
------------------------------------------------------------
revno: 32
committer: Jesse Barker <jesse.barker@linaro.org>
branch nick: trunk
timestamp: Thu 2012-01-26 09:31:27 -0800
message:
  Only emit the colon character if the prefix is non-empty.
modified:
  log.cc


--
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
diff mbox

Patch

=== modified file 'log.cc'
--- log.cc	2012-01-26 16:12:35 +0000
+++ log.cc	2012-01-26 17:31:27 +0000
@@ -58,16 +58,21 @@ 
      * Print the message lines prefixed with the supplied prefix.
      * If the target stream is a terminal make the prefix colored.
      */
-    string start_color;
-    string end_color;
-    static const string colon(": ");
-    if (!color.empty())
+    string linePrefix;
+    if (!prefix.empty())
     {
-        start_color = color;
-        if (color[0] != 0)
+        static const string colon(": ");
+        string start_color;
+        string end_color;
+        if (!color.empty())
         {
-            end_color = terminal_color_normal;
+            start_color = color;
+            if (color[0] != 0)
+            {
+                end_color = terminal_color_normal;
+            }
         }
+        linePrefix = start_color + prefix + end_color + colon;
     }
 
     std::string line;
@@ -83,7 +88,7 @@ 
         }
         else {
             /* Normal line, emit the prefix. */
-            stream << start_color << prefix << end_color << colon << line;
+            stream << linePrefix << line;
         }
 
         /* Only emit a newline if the original message has it. */