From 750cbee6b224532fc10971c04df556ce4bceb832 Mon Sep 17 00:00:00 2001 From: "E. Scott Daniels" Date: Fri, 7 Jun 2019 17:19:27 +0000 Subject: [PATCH] doc(log): Make err/cri/wrn tags consistent Tags in error messages were inconsistent. They are now all one of: ERR, CRI, or WRN to make it easier to search stderr. Signed-off-by: E. Scott Daniels Change-Id: I83a1d95e29296eadb3749885e1ac7f6ff0da7826 --- CMakeLists.txt | 2 +- src/rmr/common/src/rt_generic_static.c | 10 +++++----- src/rmr/common/src/tools_static.c | 2 +- src/rmr/nanomsg/src/rmr.c | 14 +++++++------- src/rmr/nanomsg/src/rtable_static.c | 16 ++++++++-------- src/rmr/nanomsg/src/sr_static.c | 10 +++++----- src/rmr/nng/src/rmr_nng.c | 8 ++++---- src/rmr/nng/src/rtable_nng_static.c | 14 +++++++------- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d40e80..fa6ff1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ cmake_minimum_required( VERSION 3.5 ) set( major_version "1" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this set( minor_version "0" ) -set( patch_level "30" ) +set( patch_level "31" ) set( install_root "${CMAKE_INSTALL_PREFIX}" ) set( install_lib "lib" ) diff --git a/src/rmr/common/src/rt_generic_static.c b/src/rmr/common/src/rt_generic_static.c index d51a44c..d19c839 100644 --- a/src/rmr/common/src/rt_generic_static.c +++ b/src/rmr/common/src/rt_generic_static.c @@ -173,7 +173,7 @@ static char* ensure_nlterm( char* buf ) { } } else { if( buf[len-1] != '\n' ) { - fprintf( stderr, "[WARN] rmr buf_check: input buffer was not newline terminated (file missing final \\n?)\n" ); + fprintf( stderr, "[WRN] rmr buf_check: input buffer was not newline terminated (file missing final \\n?)\n" ); if( (nb = (char *) malloc( sizeof( char ) * (len + 2) )) != NULL ) { memcpy( nb, buf, len ); *(nb+len) = '\n'; // insert \n and nil into the two extra bytes we allocated @@ -541,8 +541,8 @@ static void read_static_rt( uta_ctx_t* ctx, int vlevel ) { if( (eor = strchr( rec, '\n' )) != NULL ) { *eor = 0; } else { - fprintf( stderr, "[WARN] rmr read_static: seed route table had malformed records (missing newline): %s\n", fname ); - fprintf( stderr, "[WARN] rmr read_static: seed route table not used: %s\n", fname ); + fprintf( stderr, "[WRN] rmr read_static: seed route table had malformed records (missing newline): %s\n", fname ); + fprintf( stderr, "[WRN] rmr read_static: seed route table not used: %s\n", fname ); free( fbuf ); return; } @@ -847,14 +847,14 @@ static endpoint_t* rt_ensure_ep( route_table_t* rt, char const* ep_name ) { endpoint_t* ep; if( !rt || !ep_name || ! *ep_name ) { - fprintf( stderr, "[WARN] rmr: rt_ensure: internal mishap, something undefined rt=%p ep_name=%p\n", rt, ep_name ); + fprintf( stderr, "[WRN] rmr: rt_ensure: internal mishap, something undefined rt=%p ep_name=%p\n", rt, ep_name ); errno = EINVAL; return NULL; } if( (ep = uta_get_ep( rt, ep_name )) == NULL ) { // not there yet, make if( (ep = (endpoint_t *) malloc( sizeof( *ep ) )) == NULL ) { - fprintf( stderr, "[WARN] rmr: rt_ensure: malloc failed for endpoint creation: %s\n", ep_name ); + fprintf( stderr, "[WRN] rmr: rt_ensure: malloc failed for endpoint creation: %s\n", ep_name ); errno = ENOMEM; return NULL; } diff --git a/src/rmr/common/src/tools_static.c b/src/rmr/common/src/tools_static.c index 069911d..3aa5c43 100644 --- a/src/rmr/common/src/tools_static.c +++ b/src/rmr/common/src/tools_static.c @@ -150,7 +150,7 @@ static char* uta_h2ip( char const* hname ) { hent = gethostbyname( dname ); if( hent == NULL || hent->h_addr_list == NULL ) { - //fprintf( stderr, "[WARN] h2ip: dns lookup failed for: %s\n", dname ); + //fprintf( stderr, "[WRN] h2ip: dns lookup failed for: %s\n", dname ); free( dname ); return NULL; } diff --git a/src/rmr/nanomsg/src/rmr.c b/src/rmr/nanomsg/src/rmr.c index 128039d..256ea3b 100644 --- a/src/rmr/nanomsg/src/rmr.c +++ b/src/rmr/nanomsg/src/rmr.c @@ -598,7 +598,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { if( max_msg_size <= ctx->max_plen ) { // user defined len can be smaller ctx->max_plen = max_msg_size; } else { - fprintf( stderr, "[WARN] rmr_init: attempt to set max payload len > than allowed maximum; capped at %d bytes\n", ctx->max_plen ); + fprintf( stderr, "[WRN] rmr_init: attempt to set max payload len > than allowed maximum; capped at %d bytes\n", ctx->max_plen ); } } @@ -608,7 +608,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { ctx->nn_sock = nn_socket( AF_SP, NN_PULL ); // our 'listen' socket should allow multiple senders to connect if( ctx->nn_sock < 0 ) { - fprintf( stderr, "[CRIT] rmr_init: unable to initialise nanomsg listen socket: %d\n", errno ); + fprintf( stderr, "[CRI] rmr_init: unable to initialise nanomsg listen socket: %d\n", errno ); free_ctx( ctx ); return NULL; } @@ -625,7 +625,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { } if( (gethostname( wbuf, sizeof( wbuf ) )) < 0 ) { - fprintf( stderr, "[CRIT] rmr_init: cannot determine localhost name: %s\n", strerror( errno ) ); + fprintf( stderr, "[CRI] rmr_init: cannot determine localhost name: %s\n", strerror( errno ) ); return NULL; } if( (tok = strchr( wbuf, '.' )) != NULL ) { @@ -633,7 +633,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { } ctx->my_name = (char *) malloc( sizeof( char ) * RMR_MAX_SRC ); if( snprintf( ctx->my_name, RMR_MAX_SRC, "%s:%s", wbuf, port ) >= RMR_MAX_SRC ) { // our registered name is host:port - fprintf( stderr, "[CRIT] rmr_init: hostname + port must be less than %d characters; %s:%s is not\n", RMR_MAX_SRC, wbuf, port ); + fprintf( stderr, "[CRI] rmr_init: hostname + port must be less than %d characters; %s:%s is not\n", RMR_MAX_SRC, wbuf, port ); return NULL; } @@ -642,7 +642,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { } snprintf( bind_info, sizeof( bind_info ), "%s://%s:%s", proto, interface, port ); if( nn_bind( ctx->nn_sock, bind_info ) < 0) { // bind and automatically accept client sessions - fprintf( stderr, "[CRIT] rmr_init: unable to bind nanomsg listen socket for %s: %s\n", bind_info, strerror( errno ) ); + fprintf( stderr, "[CRI] rmr_init: unable to bind nanomsg listen socket for %s: %s\n", bind_info, strerror( errno ) ); nn_close( ctx->nn_sock ); free_ctx( ctx ); return NULL; @@ -662,7 +662,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { ctx->my_ip = get_default_ip( ctx->ip_list ); // and (guess) at what should be the default to put into messages as src if( ctx->my_ip == NULL ) { strcpy( ctx->my_ip, ctx->my_name ); // revert to name if we cant suss out ip address - fprintf( stderr, "[WARN] rmr_init: default ip address could not be sussed out, using name as source\n" ); + fprintf( stderr, "[WRN] rmr_init: default ip address could not be sussed out, using name as source\n" ); } else { if( DEBUG ) fprintf( stderr, "[DBUG] default ip address: %s\n", ctx->my_ip ); } @@ -670,7 +670,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { if( ! (flags & FL_NOTHREAD) ) { // skip if internal context that does not need rout table thread if( pthread_create( &ctx->rtc_th, NULL, rtc, (void *) ctx ) ) { // kick the rt collector thread - fprintf( stderr, "[WARN] rmr_init: unable to start route table collector thread: %s", strerror( errno ) ); + fprintf( stderr, "[WRN] rmr_init: unable to start route table collector thread: %s", strerror( errno ) ); } } diff --git a/src/rmr/nanomsg/src/rtable_static.c b/src/rmr/nanomsg/src/rtable_static.c index 643f00a..d9684f1 100644 --- a/src/rmr/nanomsg/src/rtable_static.c +++ b/src/rmr/nanomsg/src/rtable_static.c @@ -58,13 +58,13 @@ static int uta_link2( char* target ) { nn_sock = nn_socket( AF_SP, NN_PUSH ); // the socket we'll use to connect to the target if( nn_sock < 0 ) { - fprintf( stderr, "[WARN] rmr: link2: unable to create socket for link to target: %s: %d\n\n\n", target, errno ); + fprintf( stderr, "[WRN] rmr: link2: unable to create socket for link to target: %s: %d\n\n\n", target, errno ); return -1; } snprintf( conn_info, sizeof( conn_info ), "tcp://%s", target ); if( nn_connect( nn_sock, conn_info ) < 0 ) { // connect failed - fprintf( stderr, "[WARN] rmr: link2: unable to create link to target: %s: %d\n\n\n", target, errno ); + fprintf( stderr, "[WRN] rmr: link2: unable to create link to target: %s: %d\n\n\n", target, errno ); nn_close( nn_sock ); return -1; } @@ -102,24 +102,24 @@ static endpoint_t* uta_add_ep( route_table_t* rt, rtable_ent_t* rte, char* ep_n rrgroup_t* rrg; // pointer at group to update if( ! rte || ! rt ) { - fprintf( stderr, "[WARN] rmr_add_ep didn't get a valid rt and/or rte pointer\n" ); + fprintf( stderr, "[WRN] rmr_add_ep didn't get a valid rt and/or rte pointer\n" ); return NULL; } if( rte->nrrgroups <= group ) { - fprintf( stderr, "[WARN] rmr_add_ep group out of range: %d (max == %d)\n", group, rte->nrrgroups ); + fprintf( stderr, "[WRN] rmr_add_ep group out of range: %d (max == %d)\n", group, rte->nrrgroups ); return NULL; } if( (rrg = rte->rrgroups[group]) == NULL ) { if( (rrg = (rrgroup_t *) malloc( sizeof( *rrg ) )) == NULL ) { - fprintf( stderr, "[WARN] rmr_add_ep: malloc failed for round robin group: group=%d\n", group ); + fprintf( stderr, "[WRN] rmr_add_ep: malloc failed for round robin group: group=%d\n", group ); return NULL; } memset( rrg, 0, sizeof( *rrg ) ); if( (rrg->epts = (endpoint_t **) malloc( sizeof( endpoint_t ) * MAX_EP_GROUP )) == NULL ) { - fprintf( stderr, "[WARN] rmr_add_ep: malloc failed for group endpoint array: group=%d\n", group ); + fprintf( stderr, "[WRN] rmr_add_ep: malloc failed for group endpoint array: group=%d\n", group ); return NULL; } memset( rrg->epts, 0, sizeof( endpoint_t ) * MAX_EP_GROUP ); @@ -133,7 +133,7 @@ static endpoint_t* uta_add_ep( route_table_t* rt, rtable_ent_t* rte, char* ep_n if( (ep = uta_get_ep( rt, ep_name )) == NULL ) { // not there yet, make if( (ep = (endpoint_t *) malloc( sizeof( *ep ) )) == NULL ) { - fprintf( stderr, "uta: [WARN] malloc failed for endpoint creation: %s\n", ep_name ); + fprintf( stderr, "uta: [WRN] malloc failed for endpoint creation: %s\n", ep_name ); return NULL; } @@ -148,7 +148,7 @@ static endpoint_t* uta_add_ep( route_table_t* rt, rtable_ent_t* rte, char* ep_n if( rrg != NULL ) { if( rrg->nused >= rrg->nendpts ) { // future: reallocate - fprintf( stderr, "[WARN] endpoint array for mtype/group %d/%d is full!\n", rte->mtype, group ); + fprintf( stderr, "[WRN] endpoint array for mtype/group %d/%d is full!\n", rte->mtype, group ); return NULL; } diff --git a/src/rmr/nanomsg/src/sr_static.c b/src/rmr/nanomsg/src/sr_static.c index 53eb5d9..4e264ff 100644 --- a/src/rmr/nanomsg/src/sr_static.c +++ b/src/rmr/nanomsg/src/sr_static.c @@ -84,7 +84,7 @@ static rmr_mbuf_t* alloc_zcmsg( uta_ctx_t* ctx, rmr_mbuf_t* msg, int size, int s if( msg == NULL ) { msg = (rmr_mbuf_t *) malloc( sizeof *msg ); if( msg == NULL ) { - fprintf( stderr, "[CRIT] rmr_alloc_zc: cannot get memory for message\n" ); + fprintf( stderr, "[CRI] rmr_alloc_zc: cannot get memory for message\n" ); exit( 1 ); } } else { @@ -94,7 +94,7 @@ static rmr_mbuf_t* alloc_zcmsg( uta_ctx_t* ctx, rmr_mbuf_t* msg, int size, int s memset( msg, 0, sizeof( *msg ) ); if( (msg->header = (uta_mhdr_t *) nn_allocmsg( mlen, 0 )) == NULL ) { // this will be released on send, so DO NOT free - fprintf( stderr, "[CRIT] rmr_alloc_zc: cannot get memory for zero copy buffer: %d\n", errno ); + fprintf( stderr, "[CRI] rmr_alloc_zc: cannot get memory for zero copy buffer: %d\n", errno ); exit( 1 ); } @@ -137,14 +137,14 @@ static inline rmr_mbuf_t* clone_msg( rmr_mbuf_t* old_msg ) { nm = (rmr_mbuf_t *) malloc( sizeof *nm ); if( nm == NULL ) { - fprintf( stderr, "[CRIT] rmr_clone: cannot get memory for message buffer\n" ); + fprintf( stderr, "[CRI] rmr_clone: cannot get memory for message buffer\n" ); exit( 1 ); } memset( nm, 0, sizeof( *nm ) ); mlen = old_msg->alloc_len; // length allocated before if( (nm->header = (uta_mhdr_t *) nn_allocmsg( mlen, 0 )) == NULL ) { // this will be released on send, so DO NOT free - fprintf( stderr, "[CRIT] rmr_clone: cannot get memory for zero copy buffer: %d\n", errno ); + fprintf( stderr, "[CRI] rmr_clone: cannot get memory for zero copy buffer: %d\n", errno ); exit( 1 ); } @@ -185,7 +185,7 @@ static inline rmr_mbuf_t* realloc_msg( rmr_mbuf_t* old_msg, int tr_len ) { mlen = old_msg->alloc_len + (tr_len - tr_old_len); // new length with trace adjustment if( DEBUG ) fprintf( stderr, "tr_realloc old size=%d new size=%d new tr_len=%d\n", (int) old_msg->alloc_len, (int) mlen, (int) tr_len ); if( (nm->header = (uta_mhdr_t *) nn_allocmsg( mlen, 0 )) == NULL ) { // this will be released on send, so DO NOT free - fprintf( stderr, "[CRIT] rmr_realloc: cannot get memory for zero copy buffer: %d\n", errno ); + fprintf( stderr, "[CRI] rmr_realloc: cannot get memory for zero copy buffer: %d\n", errno ); exit( 1 ); } diff --git a/src/rmr/nng/src/rmr_nng.c b/src/rmr/nng/src/rmr_nng.c index 8a91544..cf5e429 100644 --- a/src/rmr/nng/src/rmr_nng.c +++ b/src/rmr/nng/src/rmr_nng.c @@ -664,7 +664,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { } else { ctx->my_ip = get_default_ip( ctx->ip_list ); // and (guess) at what should be the default to put into messages as src if( ctx->my_ip == NULL ) { - fprintf( stderr, "[WARN] rmr_init: default ip address could not be sussed out, using name\n" ); + fprintf( stderr, "[WRN] rmr_init: default ip address could not be sussed out, using name\n" ); strcpy( ctx->my_ip, ctx->my_name ); // if we cannot suss it out, use the name rather than a nil pointer } } @@ -679,7 +679,7 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { // rather than using this generic listen() call. snprintf( bind_info, sizeof( bind_info ), "%s://%s:%s", proto, interface, port ); if( (state = nng_listen( ctx->nn_sock, bind_info, NULL, NO_FLAGS )) != 0 ) { - fprintf( stderr, "[CRIT] rmr_init: unable to start nng listener for %s: %s\n", bind_info, nng_strerror( state ) ); + fprintf( stderr, "[CRI] rmr_init: unable to start nng listener for %s: %s\n", bind_info, nng_strerror( state ) ); nng_close( ctx->nn_sock ); free_ctx( ctx ); return NULL; @@ -687,14 +687,14 @@ static void* init( char* uproto_port, int max_msg_size, int flags ) { if( !(flags & FL_NOTHREAD) ) { // skip if internal function that doesnt need an rtc if( pthread_create( &ctx->rtc_th, NULL, rtc, (void *) ctx ) ) { // kick the rt collector thread - fprintf( stderr, "[WARN] rmr_init: unable to start route table collector thread: %s", strerror( errno ) ); + fprintf( stderr, "[WRN] rmr_init: unable to start route table collector thread: %s", strerror( errno ) ); } } if( (flags & RMRFL_MTCALL) && ! (ctx->flags & CFL_MTC_ENABLED) ) { // mt call support is on, must start the listener thread if not running ctx->flags |= CFL_MTC_ENABLED; if( pthread_create( &ctx->mtc_th, NULL, mt_receive, (void *) ctx ) ) { // kick the receiver - fprintf( stderr, "[WARN] rmr_init: unable to start multi-threaded receiver: %s", strerror( errno ) ); + fprintf( stderr, "[WRN] rmr_init: unable to start multi-threaded receiver: %s", strerror( errno ) ); } } diff --git a/src/rmr/nng/src/rtable_nng_static.c b/src/rmr/nng/src/rtable_nng_static.c index fefa63d..875cfe6 100644 --- a/src/rmr/nng/src/rtable_nng_static.c +++ b/src/rmr/nng/src/rtable_nng_static.c @@ -102,7 +102,7 @@ static int uta_link2( endpoint_t* ep ) { snprintf( conn_info, sizeof( conn_info ), "tcp://%s", target ); if( (state = nng_dialer_create( dialer, *nn_sock, conn_info )) != 0 ) { pthread_mutex_unlock( &ep->gate ); - fprintf( stderr, "[WARN] rmr: link2: unable to create dialer for link to target: %s: %d\n", target, errno ); + fprintf( stderr, "[WRN] rmr: link2: unable to create dialer for link to target: %s: %d\n", target, errno ); nng_close( *nn_sock ); return FALSE; } @@ -112,7 +112,7 @@ static int uta_link2( endpoint_t* ep ) { if( (state = nng_dialer_start( *dialer, NO_FLAGS )) != 0 ) { // can fail immediatly (unlike nanomsg) pthread_mutex_unlock( &ep->gate ); - fprintf( stderr, "[WARN] rmr: unable to create link to target: %s: %s\n", target, nng_strerror( state ) ); + fprintf( stderr, "[WRN] rmr: unable to create link to target: %s: %s\n", target, nng_strerror( state ) ); nng_close( *nn_sock ); return FALSE; } @@ -154,24 +154,24 @@ extern endpoint_t* uta_add_ep( route_table_t* rt, rtable_ent_t* rte, char* ep_n rrgroup_t* rrg; // pointer at group to update if( ! rte || ! rt ) { - fprintf( stderr, "[WARN] uda_add_ep didn't get a valid rt and/or rte pointer\n" ); + fprintf( stderr, "[WRN] uda_add_ep didn't get a valid rt and/or rte pointer\n" ); return NULL; } if( rte->nrrgroups <= group ) { - fprintf( stderr, "[WARN] uda_add_ep group out of range: %d (max == %d)\n", group, rte->nrrgroups ); + fprintf( stderr, "[WRN] uda_add_ep group out of range: %d (max == %d)\n", group, rte->nrrgroups ); return NULL; } if( (rrg = rte->rrgroups[group]) == NULL ) { if( (rrg = (rrgroup_t *) malloc( sizeof( *rrg ) )) == NULL ) { - fprintf( stderr, "[WARN] rmr_add_ep: malloc failed for round robin group: group=%d\n", group ); + fprintf( stderr, "[WRN] rmr_add_ep: malloc failed for round robin group: group=%d\n", group ); return NULL; } memset( rrg, 0, sizeof( *rrg ) ); if( (rrg->epts = (endpoint_t **) malloc( sizeof( endpoint_t ) * MAX_EP_GROUP )) == NULL ) { - fprintf( stderr, "[WARN] rmr_add_ep: malloc failed for group endpoint array: group=%d\n", group ); + fprintf( stderr, "[WRN] rmr_add_ep: malloc failed for group endpoint array: group=%d\n", group ); return NULL; } memset( rrg->epts, 0, sizeof( endpoint_t ) * MAX_EP_GROUP ); @@ -188,7 +188,7 @@ extern endpoint_t* uta_add_ep( route_table_t* rt, rtable_ent_t* rte, char* ep_n if( rrg != NULL ) { if( rrg->nused >= rrg->nendpts ) { // future: reallocate - fprintf( stderr, "[WARN] endpoint array for mtype/group %d/%d is full!\n", rte->mtype, group ); + fprintf( stderr, "[WRN] endpoint array for mtype/group %d/%d is full!\n", rte->mtype, group ); return NULL; } -- 2.16.6