Add additional env variable dump during init

If the RMR_LOG_VLEVEL environment is set to 4 or greater
the settingf for the environment variables that are
significant to RMR are written to stderr.

Issue-ID: RIC-630

Signed-off-by: E. Scott Daniels <daniels@research.att.com>
Change-Id: I6709f2c6d6c592494b0a7edbf23b6bd234715262
diff --git a/CHANGES_CORE.txt b/CHANGES_CORE.txt
index c325496..4df9b24 100644
--- a/CHANGES_CORE.txt
+++ b/CHANGES_CORE.txt
@@ -5,6 +5,10 @@
 # API and build change  and fix summaries. Doc correctsions
 # and/or changes are not mentioned here; see the commit messages.
 
+2020 August 4; Version 4.2.1
+	Add additional environment variable dump if RMR_LOG_VLEVEL set to
+	4 at start.
+
 2020 August 3; Version 4.2.0
 	Add support for the RMR_RTREQ_FREQ environment variable to control
 	the request frequency for a new route table (default 5s if not
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a936fd..2479654 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,7 @@
 
 set( major_version "4" )		# should be automatically populated from git tag later, but until CI process sets a tag we use this
 set( minor_version "2" )
-set( patch_level "0" )
+set( patch_level "1" )
 
 set( install_root "${CMAKE_INSTALL_PREFIX}" )
 set( install_inc "include/rmr" )
diff --git a/docs/rel-notes.rst b/docs/rel-notes.rst
index e6ac54b..3399fe4 100644
--- a/docs/rel-notes.rst
+++ b/docs/rel-notes.rst
@@ -22,6 +22,14 @@
 version 4.0.0, the RMR versions should no longer skip.
 
 
+2020 August 4; Version 4.2.1
+----------------------------
+
+Add additional environment variable dump if RMR_LOG_VLEVEL
+set to 4 at start.
+
+
+
 2020 August 3; Version 4.2.0
 ----------------------------
 
diff --git a/src/rmr/common/src/rtc_static.c b/src/rmr/common/src/rtc_static.c
index e92e53d..c1bad15 100644
--- a/src/rmr/common/src/rtc_static.c
+++ b/src/rmr/common/src/rtc_static.c
@@ -279,7 +279,7 @@
 		rt_req_freq = atoi( eptr );
 		if( rt_req_freq < 1 || rt_req_freq > 300 ) {
 			rt_req_freq = DEF_RTREQ_FREQ;
-			rmr_vlog( RMR_VL_WARN, "rmr_rtc: RT request frequency (%s) out of range (1-300), using default", DEF_RTREQ_FREQ );
+			rmr_vlog( RMR_VL_WARN, "rmr_rtc: RT request frequency (%d) out of range (1-300), using default", DEF_RTREQ_FREQ );
 		}
 	}
 	rmr_vlog( RMR_VL_INFO, "rmr_rtc: RT request frequency set to: %d seconds", rt_req_freq );
diff --git a/src/rmr/common/src/tools_static.c b/src/rmr/common/src/tools_static.c
index b4245cd..df49dd8 100644
--- a/src/rmr/common/src/tools_static.c
+++ b/src/rmr/common/src/tools_static.c
@@ -29,6 +29,9 @@
 
 					uta_link2	-- establish a nanomsg connection to a host
 
+					uta_dump_env -- dump the environment variables to stdout that are
+								of importance to RMR.
+
 	Author:		E. Scott Daniels
 	Date:		30 November 2018
 */
@@ -88,9 +91,9 @@
 	Given a buffer of 'sep' separated tokens, and a list of things,
 	return up to max tokens with any tokens that matched things in
 	the list. Toks is the user supplied array of char* which we will
-	fill in (up to max) with pointers to tokens from buf.  This 
-	damages buf, so the caller must dup the string if it must be 
-	preserved for later, original, use.  The pointers returned in 
+	fill in (up to max) with pointers to tokens from buf.  This
+	damages buf, so the caller must dup the string if it must be
+	preserved for later, original, use.  The pointers returned in
 	toks will reference portions of bufs.
 
 	Returns the number of tokens referenced by toks.
@@ -102,7 +105,7 @@
 	int i;
 	int j;
 
-	
+
 	all_toks = malloc( sizeof( char * ) * max );					// refernce to all tokens; we'll prune
 	pcount = ntoks = uta_tokenise( buf, all_toks, max, sep );		// split them up
 	j = 0;
@@ -284,7 +287,7 @@
 	to the list so that we don't pick up entries from the rtable that are for other
 	processes listening on different interfaces.
 
-	The ENV_BIN_IF environment variable may be either an IP address (v6 must be in 
+	The ENV_BIN_IF environment variable may be either an IP address (v6 must be in
 	square braces), or an interface name (e.g. eth0).
 */
 if_addrs_t*  mk_ip_list( char* port ) {
@@ -460,4 +463,37 @@
 	return NULL;
 }
 
+/*
+	Write all environment variables that we consider to be important to stderr.
+*/
+static void uta_dump_env( ) {
+	char* token;
+	char* elist[] = {
+			ENV_BIND_IF,
+			ENV_RTG_PORT,
+			ENV_RTG_ADDR,
+			ENV_SEED_RT,
+			ENV_SEED_MEMAP,
+			ENV_RTG_RAW,
+			ENV_VERBOSE_FILE,
+			ENV_NAME_ONLY,
+			ENV_WARNINGS,
+			ENV_SRC_ID,
+			ENV_LOG_HR,
+			ENV_LOG_VLEVEL,
+			ENV_CTL_PORT,
+			ENV_RTREQ_FREA
+	};
+	int i;
+
+	for( i = 0; i < sizeof( elist ) / sizeof( char *); i ++ ) {
+		token = getenv( elist[i] );
+		if( token != NULL ) {
+			rmr_vlog( RMR_VL_INFO, "dump_env: %s = '%s'\n", elist[i], token );
+		} else {
+			rmr_vlog( RMR_VL_INFO, "dump_env: %s = <unset>\n", elist[i] );
+		}
+	}
+}
+
 #endif
diff --git a/src/rmr/si/src/rmr_si.c b/src/rmr/si/src/rmr_si.c
index 7a2bc96..93475f9 100644
--- a/src/rmr/si/src/rmr_si.c
+++ b/src/rmr/si/src/rmr_si.c
@@ -556,14 +556,16 @@
 	int		old_vlevel;
 
 	old_vlevel = rmr_vlog_init();			// initialise and get the current level
-	rmr_set_vlevel( RMR_VL_INFO );		// we WILL announce our version etc
 
 	if( ! announced ) {
+		rmr_set_vlevel( RMR_VL_INFO );		// we WILL announce our version
 		rmr_vlog( RMR_VL_INFO, "ric message routing library on SI95/g mv=%d flg=%02x (%s %s.%s.%s built: %s)\n",
 			RMR_MSG_VER, flags, QUOTE_DEF(GIT_ID), QUOTE_DEF(MAJOR_VER), QUOTE_DEF(MINOR_VER), QUOTE_DEF(PATCH_VER), __DATE__ );
 		announced = 1;
+
+		rmr_set_vlevel( old_vlevel );		// return logging to the desired state
+		uta_dump_env();							// spit out environment settings meaningful to us if in info mode
 	}
-	rmr_set_vlevel( old_vlevel );		// return logging to the desired state
 
 	errno = 0;
 	if( uproto_port == NULL ) {
diff --git a/test/rmr_si_api_static_test.c b/test/rmr_si_api_static_test.c
index b7f97bf..5424e98 100644
--- a/test/rmr_si_api_static_test.c
+++ b/test/rmr_si_api_static_test.c
@@ -264,6 +264,25 @@
 	rmr_set_low_latency( NULL );
 	rmr_set_fack( NULL );
 
+
+	msg2 = rmr_alloc_msg( rmc,  1024 );
+	msg2 = rmr_rcv_msg( NULL, msg2 );
+	if( msg2 != NULL ) {
+		errors += fail_if( msg2->state == RMR_OK, "nil context check for rcv msg returned OK" );
+	}
+	msg2 = rmr_torcv_msg( NULL, msg2, 200 );
+	if( msg2 != NULL ) {
+		errors += fail_if( msg2->state == RMR_OK, "nil context check for torcv msg returned OK" );
+	}
+
+	//  ----- thread start coverage ---------------------------------------------------------------------------
+	setenv( "RMR_WARNINGS", "1", 1 );	// force non-default branches during these tests
+	setenv( "RMR_SRC_NAMEONLY", "1", 1 );
+
+	rmr_init( ":6789", 1024, 0 );		// threaded mode with defined/default RM target
+	setenv( "RMR_RTG_SVC", "-1", 1 );	// force into static table mode
+	rmr_init( ":6789", 1024, 0 );		// threaded mode with static table
+
 	// --------------- phew, done ------------------------------------------------------------------------------
 
 	if( ! errors ) {
diff --git a/test/sr_si_static_test.c b/test/sr_si_static_test.c
index be99359..e3b5a77 100644
--- a/test/sr_si_static_test.c
+++ b/test/sr_si_static_test.c
@@ -147,6 +147,10 @@
 	rtc_file( NULL );			// the static file only collector
 	rtc_file( ctx );
 
+	setenv( "RMR_RTREQ_FREQ", "400", 1 );	// force error checking code in rtc to resort to default
+	rtc( ctx );
+
+	setenv( "RMR_CTL_PORT", "43086", 1 );	// force defined branch in rtc
 	rtc( ctx );
 
 	setenv( "RMR_RTG_SVC", "4567", 1 );		// drive for edge case coverage to ensure no nil pointer etc
diff --git a/test/tools_static_test.c b/test/tools_static_test.c
index 0269522..f1c2ffc 100644
--- a/test/tools_static_test.c
+++ b/test/tools_static_test.c
@@ -77,6 +77,8 @@
 	void*	if_list;
 
 
+	uta_dump_env();
+
 	// ------------------ tokenise tests -----------------------------------------------------------
 	dbuf = strdup( buf );
 	i = uta_tokenise( dbuf, tokens, 127, ',' );
diff --git a/test/tools_test.c b/test/tools_test.c
index 3a09d44..fb6aafa 100644
--- a/test/tools_test.c
+++ b/test/tools_test.c
@@ -45,6 +45,7 @@
 #define NO_EMULATION
 #include "test_support.c"		// our private library of test tools
 
+#include "logging.c"		// tools references logging, so pull in too
 #include "tools_static.c"
 
 #include "tools_static_test.c"