Change in libosmocore[master]: logging: Avoid printing OSMO_LOGCOLOR_END if no color was used

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Jul 20 15:01:17 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/19336 )


Change subject: logging: Avoid printing OSMO_LOGCOLOR_END if no color was used
......................................................................

logging: Avoid printing OSMO_LOGCOLOR_END if no color was used

There's no point in printing that code if no color was used in first
place, and looks strange when using logging with color enabled but no
color assigned to the category printing lines.

Only affected unit test output by this fix is osmo-bts'x
tx_power_test.c, which has been fixed in osmo-bts.git Change-Id
I5aa95997c8df4ce5ba8271acae99c45f68b96e11.

Change-Id: Ie38cc639d7f4acd908f357e5bfb3ced07147583e
---
M src/logging.c
M tests/fsm/fsm_test.err
2 files changed, 45 insertions(+), 45 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/36/19336/1

diff --git a/src/logging.c b/src/logging.c
index c14e696..1c3e5ce 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -500,7 +500,7 @@
 		}
 	}
 
-	if (target->use_color) {
+	if (target->use_color && c_subsys) {
 		ret = snprintf(buf + offset, rem, OSMO_LOGCOLOR_END);
 		if (ret < 0)
 			goto err;
diff --git a/tests/fsm/fsm_test.err b/tests/fsm/fsm_test.err
index 13cbacd..4cc5ca4 100644
--- a/tests/fsm/fsm_test.err
+++ b/tests/fsm/fsm_test.err
@@ -1,18 +1,18 @@
 Checking FSM allocation
-Test_FSM(my_id){NULL}: Allocated
-Test_FSM(my_id){NULL}: Received Event EV_B
-Test_FSM(my_id){NULL}: Event EV_B not permitted
-Test_FSM(my_id){NULL}: Received Event EV_A
-Test_FSM(my_id){NULL}: State change to ONE (no timeout)
-Test_FSM(my_id){ONE}: Received Event EV_B
-Test_FSM(my_id){ONE}: State change to TWO (T2342, 1s)
-Test_FSM(my_id){TWO}: Timeout of T2342
-Timer
-Test_FSM(my_id){TWO}: Deallocated
-
+Test_FSM(my_id){NULL}: Allocated
+Test_FSM(my_id){NULL}: Received Event EV_B
+Test_FSM(my_id){NULL}: Event EV_B not permitted
+Test_FSM(my_id){NULL}: Received Event EV_A
+Test_FSM(my_id){NULL}: State change to ONE (no timeout)
+Test_FSM(my_id){ONE}: Received Event EV_B
+Test_FSM(my_id){ONE}: State change to TWO (T2342, 1s)
+Test_FSM(my_id){TWO}: Timeout of T2342
+Timer
+Test_FSM(my_id){TWO}: Deallocated
+
 --- test_id_api()
 Test_FSM{NULL}: Allocated
-  osmo_fsm_inst_name() == "Test_FSM"
+  osmo_fsm_inst_name() == "Test_FSM"
   osmo_fsm_inst_find_by_name("Test_FSM") == fi
 osmo_fsm_inst_update_id("my_id")
     rc == 0, ok
@@ -39,23 +39,23 @@
   osmo_fsm_inst_find_by_id("arbitrary_id") == fi
 osmo_fsm_inst_update_id("")
 Attempting to set illegal id for FSM instance of type 'Test_FSM': ""
-    rc == -22, ok
+    rc == -22, ok
   osmo_fsm_inst_name() == "Test_FSM(arbitrary_id)"
   osmo_fsm_inst_find_by_name("Test_FSM(arbitrary_id)") == fi
 osmo_fsm_inst_update_id("invalid.id")
 Attempting to set illegal id for FSM instance of type 'Test_FSM': "invalid.id"
-    rc == -22, ok
+    rc == -22, ok
   osmo_fsm_inst_name() == "Test_FSM(arbitrary_id)"
   osmo_fsm_inst_find_by_name("Test_FSM(arbitrary_id)") == fi
 --- id format tests...
 osmo_fsm_inst_update_id_f("format%cid", '.')
 Attempting to set illegal id for FSM instance of type 'Test_FSM': "format.id"
-    rc == -22, ok
+    rc == -22, ok
   osmo_fsm_inst_name() == "Test_FSM(arbitrary_id)"
   osmo_fsm_inst_find_by_name("Test_FSM(arbitrary_id)") == fi
 osmo_fsm_inst_update_id_f("%s", "")
 Attempting to set illegal id for FSM instance of type 'Test_FSM': ""
-    rc == -22, ok
+    rc == -22, ok
   osmo_fsm_inst_name() == "Test_FSM(arbitrary_id)"
   osmo_fsm_inst_find_by_name("Test_FSM(arbitrary_id)") == fi
 osmo_fsm_inst_update_id_f("format%xid%d", 0x23, 42)
@@ -78,41 +78,41 @@
 --- test_id_api() done
 
 Test_FSM(arbitrary_id){NULL}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
-Test_FSM(arbitrary_id){NULL}: Freeing instance
-Test_FSM(arbitrary_id){NULL}: Deallocated
-
+Test_FSM(arbitrary_id){NULL}: Freeing instance
+Test_FSM(arbitrary_id){NULL}: Deallocated
+
 --- test_state_chg_keep_timer()
 Test_FSM{NULL}: Allocated
-Test_FSM{NULL}: State change to ONE (no timeout)
-Test_FSM{ONE}: State change to TWO (no timeout)
-Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
-Test_FSM{TWO}: Freeing instance
-Test_FSM{TWO}: Deallocated
-Total time passed: 0.000000 s
+Test_FSM{NULL}: State change to ONE (no timeout)
+Test_FSM{ONE}: State change to TWO (no timeout)
+Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
+Test_FSM{TWO}: Freeing instance
+Test_FSM{TWO}: Deallocated
+Total time passed: 0.000000 s
 Test_FSM{NULL}: Allocated
-Test_FSM{NULL}: State change to ONE (T10, 10s)
-Total time passed: 2.000342 s
+Test_FSM{NULL}: State change to ONE (T10, 10s)
+Total time passed: 2.000342 s
 Test_FSM{ONE}: State change to TWO (keeping T10, 7.999s remaining)
-Total time passed: 2.000342 s
+Total time passed: 2.000342 s
 Total time passed: 9.999999 s
 Total time passed: 10.000000 s
 Test_FSM{TWO}: Timeout of T10
-Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
-Test_FSM{TWO}: Freeing instance
-Test_FSM{TWO}: Deallocated
---- test_state_chg_keep_timer() done
+Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
+Test_FSM{TWO}: Freeing instance
+Test_FSM{TWO}: Deallocated
+--- test_state_chg_keep_timer() done
 
 --- test_state_chg_T()
 Test_FSM{NULL}: Allocated
-Test_FSM{NULL}: State change to ONE (T42, 23s)
-Test_FSM{ONE}: State change to TWO (no timeout)
-Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
-Test_FSM{TWO}: Freeing instance
-Test_FSM{TWO}: Deallocated
-Test_FSM{NULL}: Allocated
-Test_FSM{NULL}: State change to ONE (T42, 23s)
-Test_FSM{ONE}: State change to TWO (no timeout)
-Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
-Test_FSM{TWO}: Freeing instance
-Test_FSM{TWO}: Deallocated
---- test_state_chg_T() done
+Test_FSM{NULL}: State change to ONE (T42, 23s)
+Test_FSM{ONE}: State change to TWO (no timeout)
+Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
+Test_FSM{TWO}: Freeing instance
+Test_FSM{TWO}: Deallocated
+Test_FSM{NULL}: Allocated
+Test_FSM{NULL}: State change to ONE (T42, 23s)
+Test_FSM{ONE}: State change to TWO (no timeout)
+Test_FSM{TWO}: Terminating (cause = OSMO_FSM_TERM_REQUEST)
+Test_FSM{TWO}: Freeing instance
+Test_FSM{TWO}: Deallocated
+--- test_state_chg_T() done

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19336
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ie38cc639d7f4acd908f357e5bfb3ced07147583e
Gerrit-Change-Number: 19336
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200720/5f1aa510/attachment.htm>


More information about the gerrit-log mailing list