Welcome to little lamb

Code » anopa » commit 53c960a

output: Don't force a name & message, allow only one

author Olivier Brunel
2015-02-12 21:51:20 UTC
committer Olivier Brunel
2015-04-04 12:47:33 UTC
parent 2fc4c38bfc9aee9ed5d97d2c6e3e6f3f29bca83e

output: Don't force a name & message, allow only one

While we might often have a name (e.g. service name) to show before the
actual message, let's make that optional.

src/libanopa/output.c +15 -6

diff --git a/src/libanopa/output.c b/src/libanopa/output.c
index c963495..8de4f54 100644
--- a/src/libanopa/output.c
+++ b/src/libanopa/output.c
@@ -66,8 +66,11 @@ aa_put_err (const char *name, const char *msg, int end)
     aa_bs_noflush (AA_ERR, "==> ERROR: ");
     aa_is_noflush (AA_ERR, ANSI_HIGHLIGHT_ON);
     aa_bs_noflush (AA_ERR, name);
-    aa_bs_noflush (AA_ERR, ": ");
-    aa_bs_noflush (AA_ERR, msg);
+    if (msg)
+    {
+        aa_bs_noflush (AA_ERR, ": ");
+        aa_bs_noflush (AA_ERR, msg);
+    }
     if (end)
         aa_end_err ();
 }
@@ -79,8 +82,11 @@ aa_put_warn (const char *name, const char *msg, int end)
     aa_bs_noflush (AA_ERR, "==> WARNING: ");
     aa_is_noflush (AA_ERR, ANSI_HIGHLIGHT_ON);
     aa_bs_noflush (AA_ERR, name);
-    aa_bs_noflush (AA_ERR, ": ");
-    aa_bs_noflush (AA_ERR, msg);
+    if (msg)
+    {
+        aa_bs_noflush (AA_ERR, ": ");
+        aa_bs_noflush (AA_ERR, msg);
+    }
     if (end)
         aa_end_warn ();
 }
@@ -92,8 +98,11 @@ aa_put_title (int main, const char *name, const char *title, int end)
     aa_bs_noflush (AA_OUT, (main) ? "==> " : "  -> ");
     aa_is_noflush (AA_OUT, ANSI_HIGHLIGHT_ON);
     aa_bs_noflush (AA_OUT, name);
-    aa_bs_noflush (AA_OUT, ": ");
-    aa_bs_noflush (AA_OUT, title);
+    if (title)
+    {
+        aa_bs_noflush (AA_OUT, ": ");
+        aa_bs_noflush (AA_OUT, title);
+    }
     if (end)
         aa_end_title ();
 }