From ff6b87d8cc3e0380008b0267fd6e56445c5d9b4d Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 30 Jan 2006 04:47:49 +0000 Subject: [PATCH] Added additional param to all the osrfLog* calls which mark the file and line number of each log call git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@633 9efc2488-bf62-4759-914b-345cdb29e865 --- src/c-apps/osrf_math.c | 2 +- src/c-apps/osrf_version.c | 4 +- src/gateway/mod_ils_gateway.c | 26 ++++---- src/jserver/osrf_chat.c | 76 ++++++++++----------- src/jserver/osrf_chat_main.c | 2 +- src/libstack/osrfConfig.c | 8 +-- src/libstack/osrf_app_session.c | 48 ++++++------- src/libstack/osrf_application.c | 22 +++--- src/libstack/osrf_application.h | 16 ++--- src/libstack/osrf_cache.c | 8 +-- src/libstack/osrf_message.c | 4 +- src/libstack/osrf_prefork.c | 84 +++++++++++------------ src/libstack/osrf_settings.c | 2 +- src/libstack/osrf_stack.c | 34 +++++----- src/libstack/osrf_system.c | 22 +++--- src/libstack/osrf_transgroup.c | 14 ++-- src/libtransport/basic_client.c | 6 +- src/libtransport/component.c | 6 +- src/libtransport/transport_client.c | 4 +- src/libtransport/transport_message.c | 10 +-- src/libtransport/transport_session.c | 28 ++++---- src/router/osrf_router.c | 44 ++++++------ src/router/osrf_router_main.c | 12 ++-- src/srfsh/srfsh.c | 10 ++- src/utils/log.c | 43 +++++------- src/utils/log.h | 25 ++++--- src/utils/socket_bundle.c | 126 +++++++++++++++-------------------- src/utils/string_array.c | 4 +- 28 files changed, 330 insertions(+), 360 deletions(-) diff --git a/src/c-apps/osrf_math.c b/src/c-apps/osrf_math.c index 798c631..f307804 100644 --- a/src/c-apps/osrf_math.c +++ b/src/c-apps/osrf_math.c @@ -62,7 +62,7 @@ int osrfMathRun( osrfMethodContext* ctx ) { if( a && b ) { - osrfLogActivity( "Running opensrf.math %s [ %s : %s ]", + osrfLogActivity( OSRF_LOG_MARK, "Running opensrf.math %s [ %s : %s ]", ctx->method->name, a, b ); /* construct a new params object to send to dbmath */ diff --git a/src/c-apps/osrf_version.c b/src/c-apps/osrf_version.c index e134b2a..1affb70 100644 --- a/src/c-apps/osrf_version.c +++ b/src/c-apps/osrf_version.c @@ -40,7 +40,7 @@ int osrfVersion( osrfMethodContext* ctx ) { free(json); if( cachedmd5 ) { - osrfLogDebug( "Found %s object in cache, returning....", cachedmd5 ); + osrfLogDebug(OSRF_LOG_MARK, "Found %s object in cache, returning....", cachedmd5 ); jsonObject* resp = jsonNewObject(cachedmd5); osrfAppRespondComplete( ctx, resp ); jsonObjectFree(resp); @@ -79,7 +79,7 @@ int osrfVersion( osrfMethodContext* ctx ) { osrfAppRespondComplete( ctx, resp ); jsonObjectFree(resp); osrfAppSessionFree(ses); - osrfLogDebug("Found version string %s, caching and returning...", resultmd5 ); + osrfLogDebug(OSRF_LOG_MARK, "Found version string %s, caching and returning...", resultmd5 ); osrfCachePutString( paramsmd5, resultmd5, OSRF_VERSION_CACHE_TIME ); free(resultmd5); free(paramsmd5); diff --git a/src/gateway/mod_ils_gateway.c b/src/gateway/mod_ils_gateway.c index 59d727a..c2aace5 100644 --- a/src/gateway/mod_ils_gateway.c +++ b/src/gateway/mod_ils_gateway.c @@ -30,7 +30,7 @@ static void mod_ils_gateway_child_init(apr_pool_t *p, server_rec *s) { char* cfg = ils_gateway_config_file; if( ! osrf_system_bootstrap_client( cfg, CONFIG_CONTEXT) ) { - osrfLogError("Unable to bootstrap client in gateway..."); + osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap client in gateway..."); return; } fprintf(stderr, "Bootstrapping %d\n", getpid() ); @@ -66,12 +66,12 @@ static int mod_ils_gateway_method_handler (request_rec *r) { /* verify we are connected */ if(!osrf_system_get_transport_client()) { - osrfLogError("Bootstrap Failed, no transport client"); + osrfLogError( OSRF_LOG_MARK, "Bootstrap Failed, no transport client"); return HTTP_INTERNAL_SERVER_ERROR; } ap_set_content_type(r, "text/plain"); - osrfLogDebug("Apache request method: %s", r->method ); + osrfLogDebug( OSRF_LOG_MARK, "Apache request method: %s", r->method ); /* gather the post args and append them to the url query string */ if( !strcmp(r->method,"POST") ) { @@ -79,7 +79,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) { ap_setup_client_block(r,REQUEST_CHUNKED_DECHUNK); if(! ap_should_client_block(r)) { - osrfLogWarning("No Post Body"); + osrfLogWarning( OSRF_LOG_MARK, "No Post Body"); ap_rputs("null", r); return OK; } @@ -95,7 +95,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) { } if( buffer->n_used < 1 ) { - osrfLogWarning("No Post Body"); + osrfLogWarning( OSRF_LOG_MARK, "No Post Body"); ap_rputs("null", r); return OK; } @@ -114,12 +114,12 @@ static int mod_ils_gateway_method_handler (request_rec *r) { } if( ! arg || strlen(arg) == 0 ) { /* we received no request */ - osrfLogWarning("No Args"); + osrfLogWarning( OSRF_LOG_MARK, "No Args"); ap_rputs("null", r); return OK; } - osrfLogDebug("URL: %s", arg ); + osrfLogDebug( OSRF_LOG_MARK, "URL: %s", arg ); ap_log_rerror( APLOG_MARK, APLOG_DEBUG, 0, r, "URL: %s", arg ); r->allowed |= (AP_METHOD_BIT << M_GET); @@ -159,17 +159,17 @@ static int mod_ils_gateway_method_handler (request_rec *r) { fprintf(stderr, "DONE URL KEY: %s %d\n", key, api_level); fflush(stderr); - osrfLogInfo("\r\nPerforming(%d): service %s " + osrfLogInfo( OSRF_LOG_MARK, "\r\nPerforming(%d): service %s " "| method %s |", getpid(), service, method ); int k; for( k = 0; k!= sarray->size; k++ ) { - osrfLogInfo( "param %s", string_array_get_string(sarray,k)); + osrfLogInfo( OSRF_LOG_MARK, "param %s", string_array_get_string(sarray,k)); } osrf_app_session* session = osrf_app_client_session_init(service); - osrfLogDebug("session service: %s", session->remote_service ); + osrfLogDebug( OSRF_LOG_MARK, "session service: %s", session->remote_service ); int req_id = osrf_app_session_make_req( session, NULL, method, api_level, sarray ); string_array_destroy(sarray); @@ -189,7 +189,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) { char* s = omsg->status_name ? omsg->status_name : "Unknown Error"; char* t = omsg->status_text ? omsg->status_text : "No Error Message"; jsonObjectSetKey(response, "debug", jsonNewObject("\n\n%s:\n%s\n", s, t)); - osrfLogError( "Gateway received error: %s", + osrfLogError( OSRF_LOG_MARK, "Gateway received error: %s", jsonObjectGetString(jsonObjectGetKey(response, "debug"))); break; } @@ -201,14 +201,14 @@ static int mod_ils_gateway_method_handler (request_rec *r) { char* content = jsonObjectToJSON(response); if(content) { - osrfLogInfo( "Gateway responding with: %s", content ); + osrfLogInfo( OSRF_LOG_MARK, "Gateway responding with: %s", content ); ap_rputs(content,r); free(content); } jsonObjectFree(response); osrf_app_session_request_finish( session, req_id ); - osrfLogDebug("gateway processed message successfully"); + osrfLogDebug( OSRF_LOG_MARK, "gateway processed message successfully"); osrf_app_session_destroy(session); return OK; diff --git a/src/jserver/osrf_chat.c b/src/jserver/osrf_chat.c index a6a75ec..8981c49 100644 --- a/src/jserver/osrf_chat.c +++ b/src/jserver/osrf_chat.c @@ -67,7 +67,7 @@ static void chatdbg( osrfChatServer* server ) { node->to, node->resource, node->username, node->domain, node->authkey, node->type ); } - osrfLogDebug("DEBUG:\n%s", buf->buf ); + osrfLogDebug( OSRF_LOG_MARK, "DEBUG:\n%s", buf->buf ); buffer_free(buf); osrfListIteratorFree(itr); } @@ -182,7 +182,7 @@ int osrfChatServerWait( osrfChatServer* server ) { if(!server) return -1; while(1) { if(socket_wait_all(server->mgr, -1) < 0) - osrfLogWarning( "jserver_wait(): socket_wait_all() returned error"); + osrfLogWarning( OSRF_LOG_MARK, "jserver_wait(): socket_wait_all() returned error"); } return -1; } @@ -207,16 +207,16 @@ void osrfChatHandleData( void* cs, osrfChatNode* node = osrfListGetIndex( server->nodeList, sockid ); if(node) - osrfLogDebug("Found node for sockid %d with state %d", sockid, node->state); + osrfLogDebug( OSRF_LOG_MARK, "Found node for sockid %d with state %d", sockid, node->state); if(!node) { - osrfLogDebug("Adding new connection for sockid %d", sockid ); + osrfLogDebug( OSRF_LOG_MARK, "Adding new connection for sockid %d", sockid ); node = osrfChatAddNode( server, sockid ); } if(node) { if( (osrfChatPushData( server, node, data ) == -1) ) { - osrfLogWarning("Node at socket %d received bad XML, disconnecting...", sockid ); + osrfLogWarning( OSRF_LOG_MARK, "Node at socket %d received bad XML, disconnecting...", sockid ); osrfChatSendRaw( node, OSRF_CHAT_PARSE_ERROR ); osrfChatRemoveNode( server, node ); } @@ -275,7 +275,7 @@ int osrfChatSend( osrfChatServer* cs, osrfChatNode* node, char* toAddr, char* fr if( eq( dombuf, cs->domain ) ) { /* this is to a user we host */ - osrfLogInfo("Sending message on local connection\nfrom: %s\nto: %s", fromAddr, toAddr ); + osrfLogInfo( OSRF_LOG_MARK, "Sending message on local connection\nfrom: %s\nto: %s", fromAddr, toAddr ); osrfChatNode* tonode = osrfHashGet(cs->nodeHash, toAddr); if(tonode) { osrfChatSendRaw( tonode, msgXML ); @@ -283,7 +283,7 @@ int osrfChatSend( osrfChatServer* cs, osrfChatNode* node, char* toAddr, char* fr } else { /* send an error message saying we don't have this connection */ - osrfLogInfo("We have no connection for %s", toAddr); + osrfLogInfo( OSRF_LOG_MARK, "We have no connection for %s", toAddr); char* xml = va_list_to_string( OSRF_CHAT_NO_RECIPIENT, toAddr, fromAddr ); osrfChatSendRaw( node, xml ); free(xml); @@ -294,18 +294,18 @@ int osrfChatSend( osrfChatServer* cs, osrfChatNode* node, char* toAddr, char* fr osrfChatNode* tonode = osrfHashGet(cs->nodeHash, dombuf); if(tonode) { if( tonode->state == OSRF_CHAT_STATE_CONNECTED ) { - osrfLogDebug("Routing message to server %s", dombuf); + osrfLogDebug( OSRF_LOG_MARK, "Routing message to server %s", dombuf); osrfChatSendRaw( tonode, msgXML ); } else { - osrfLogInfo("Received s2s message and we're still trying to connect...caching"); + osrfLogInfo( OSRF_LOG_MARK, "Received s2s message and we're still trying to connect...caching"); osrfListPush( tonode->msgs, strdup(msgXML) ); } } else { if( osrfChatInitS2S( cs, dombuf, toAddr, msgXML ) != 0 ) { - osrfLogWarning("We are unable to connect to remote server %s for recipient %s", dombuf, toAddr); + osrfLogWarning( OSRF_LOG_MARK, "We are unable to connect to remote server %s for recipient %s", dombuf, toAddr); char* xml = va_list_to_string( OSRF_CHAT_NO_RECIPIENT, toAddr, fromAddr ); osrfChatSendRaw( node, xml ); free(xml); @@ -323,7 +323,7 @@ void osrfChatCacheS2SMessage( char* toAddr, char* msgXML, osrfChatNode* snode ) osrfChatS2SMessage* msg = safe_malloc(sizeof(osrfChatS2SMessage)); msg->toAddr = strdup(toAddr); msg->msgXML = strdup(msgXML); - osrfLogInfo("Pushing client message onto s2s queue waiting for connect... "); + osrfLogInfo( OSRF_LOG_MARK, "Pushing client message onto s2s queue waiting for connect... "); osrfListPush( snode->msgs, msgXML ); } */ @@ -332,14 +332,14 @@ void osrfChatCacheS2SMessage( char* toAddr, char* msgXML, osrfChatNode* snode ) int osrfChatInitS2S( osrfChatServer* cs, char* remote, char* toAddr, char* msgXML ) { if(!(cs && remote && toAddr && msgXML)) return -1; - osrfLogInfo("Initing server2server connection to domain %s", remote ); + osrfLogInfo( OSRF_LOG_MARK, "Initing server2server connection to domain %s", remote ); osrfChatNode* snode = osrfNewChatS2SNode( cs->domain, remote ); snode->parent = cs; /* try to connect to the remote site */ snode->sockid = socket_open_tcp_client(cs->mgr, cs->s2sport, remote); if(snode->sockid < 1) { - osrfLogWarning("Unable to connect to remote server at %s", remote ); + osrfLogWarning( OSRF_LOG_MARK, "Unable to connect to remote server at %s", remote ); return -1; } @@ -352,7 +352,7 @@ int osrfChatInitS2S( osrfChatServer* cs, char* remote, char* toAddr, char* msgXM /* send the initial s2s request */ osrfChatSendRaw( snode, OSRF_CHAT_S2S_INIT ); - osrfLogDebug("Added new s2s node..."); + osrfLogDebug( OSRF_LOG_MARK, "Added new s2s node..."); chatdbg(cs); return 0; @@ -366,7 +366,7 @@ int osrfChatPushData( osrfChatServer* server, osrfChatNode* node, char* data ) { chatdbg(server); - osrfLogDebug("pushing data into xml parser for node %d with state %d:\n%s", + osrfLogDebug( OSRF_LOG_MARK, "pushing data into xml parser for node %d with state %d:\n%s", node->sockid, node->state, data); node->inparse = 1; xmlParseChunk(node->parserCtx, data, strlen(data), 0); @@ -391,7 +391,7 @@ int osrfChatPushData( osrfChatServer* server, osrfChatNode* node, char* data ) { void osrfChatStartStream( void* blob ) { - osrfLogDebug("Starting new client stream..."); + osrfLogDebug( OSRF_LOG_MARK, "Starting new client stream..."); } @@ -402,14 +402,14 @@ void osrfChatStartElement( void* blob, const xmlChar *name, const xmlChar **atts int status = -1; char* nm = (char*) name; - osrfLogDebug("Starting element %s with namespace %s and node state %d", + osrfLogDebug( OSRF_LOG_MARK, "Starting element %s with namespace %s and node state %d", nm, xmlSaxAttr(atts, "xmlns"), node->state ); switch( node->state ) { case OSRF_CHAT_STATE_NONE: status = osrfChatHandleNewConnection( node, nm, atts ); - osrfLogDebug("After NewConnection we have state %d", node->state); + osrfLogDebug( OSRF_LOG_MARK, "After NewConnection we have state %d", node->state); break; case OSRF_CHAT_STATE_CONNECTING: @@ -458,7 +458,7 @@ void osrfChatStartElement( void* blob, const xmlChar *name, const xmlChar **atts osrfChatParseError( node, "We don't know how to handle the XML data received" ); } -#define CHAT_CHECK_VARS(x,y,z) if(!(x && y)) return -1; if(z) osrfLogDebug(z); +#define CHAT_CHECK_VARS(x,y,z) if(!(x && y)) return -1; if(z) osrfLogDebug( OSRF_LOG_MARK, z); @@ -486,7 +486,7 @@ int osrfChatHandleS2SConnected( osrfChatNode* node, const char* name, const xmlC char* from = (char*) xmlGetProp(xmlDocGetRootElement(doc), BAD_CAST "from"); char* to = (char*) xmlGetProp(xmlDocGetRootElement(doc), BAD_CAST "to"); osrfChatSend( node->parent, node, to, from, xml ); - osrfLogDebug("Sending cached message from %s to %s", from, to); + osrfLogDebug( OSRF_LOG_MARK, "Sending cached message from %s to %s", from, to); xmlFree(to); xmlFree(from); xmlFreeDoc(doc); } @@ -499,7 +499,7 @@ int osrfChatHandleS2SConnected( osrfChatNode* node, const char* name, const xmlC } if(status == 0) { - osrfLogInfo("Successfully made S2S connection to %s", node->remote ); + osrfLogInfo( OSRF_LOG_MARK, "Successfully made S2S connection to %s", node->remote ); node->state = OSRF_CHAT_STATE_CONNECTED; node->xmlstate = 0; } @@ -524,17 +524,17 @@ int osrfChatHandleNewConnection( osrfChatNode* node, const char* name, const xml if(!domain) return -1; if(!eq(domain, node->domain)) { - osrfLogWarning("Client attempting to connect to invalid domain"); + osrfLogWarning( OSRF_LOG_MARK, "Client attempting to connect to invalid domain"); return -1; } char* buf = va_list_to_string( OSRF_CHAT_START_STREAM, domain, node->authkey ); node->state = OSRF_CHAT_STATE_CONNECTING; - osrfLogDebug("Server node %d setting state to OSRF_CHAT_STATE_CONNECTING[%d]", + osrfLogDebug( OSRF_LOG_MARK, "Server node %d setting state to OSRF_CHAT_STATE_CONNECTING[%d]", node->sockid, node->state ); - osrfLogDebug("Server responding to connect message with\n%s\n", buf ); + osrfLogDebug( OSRF_LOG_MARK, "Server responding to connect message with\n%s\n", buf ); osrfChatSendRaw( node, buf ); free(buf); return 0; @@ -542,7 +542,7 @@ int osrfChatHandleNewConnection( osrfChatNode* node, const char* name, const xml /* server to server init */ if(eq(ns, "jabber:server")) { /* client connection */ - osrfLogInfo("We received a new server 2 server connection, generating auth key..."); + osrfLogInfo( OSRF_LOG_MARK, "We received a new server 2 server connection, generating auth key..."); char* xml = va_list_to_string( OSRF_CHAT_S2S_CHALLENGE, node->authkey ); osrfChatSendRaw( node, xml ); free(xml); @@ -565,7 +565,7 @@ char* osrfChatMkAuthKey() { int osrfChatHandleConnecting( osrfChatNode* node, const char* name, const xmlChar** atts ) { CHAT_CHECK_VARS(node, name, "osrfChatHandleConnecting()"); - osrfLogDebug("Handling connect node %s", name ); + osrfLogDebug( OSRF_LOG_MARK, "Handling connect node %s", name ); if(eq(name, "iq")) node->xmlstate |= OSRF_CHAT_STATE_INIQ; else if(eq(name,"username")) node->xmlstate |= OSRF_CHAT_STATE_INUSERNAME; @@ -605,12 +605,12 @@ int osrfChatHandleConnected( osrfChatNode* node, const char* name, const xmlChar /* takes s2s secret, hashdomain, and the s2s auth token */ static char* osrfChatGenerateS2SKey( char* secret, char* hashdomain, char* authtoken ) { if(!(secret && hashdomain && authtoken)) return NULL; - osrfLogInfo("Generating s2s key with auth token: %s", authtoken ); + osrfLogInfo( OSRF_LOG_MARK, "Generating s2s key with auth token: %s", authtoken ); char* a = shahash(secret); - osrfLogDebug("S2S secret hash: %s", a); + osrfLogDebug( OSRF_LOG_MARK, "S2S secret hash: %s", a); char* b = va_list_to_string("%s%s", a, hashdomain); char* c = shahash(b); - osrfLogDebug("S2S intermediate hash: %s", c); + osrfLogDebug( OSRF_LOG_MARK, "S2S intermediate hash: %s", c); char* d = va_list_to_string("%s%s", c, authtoken); char* e = strdup(shahash(d)); free(b); free(d); @@ -627,7 +627,7 @@ int osrfChatHandleS2SChallenge( osrfChatNode* node, const char* name, const xmlC /* we use our domain in the s2s challenge hash */ char* d = osrfChatGenerateS2SKey(node->parent->secret, node->domain, id ); char* e = va_list_to_string(OSRF_CHAT_S2S_RESPONSE, node->remote, node->domain, d ); - osrfLogInfo("Answering s2s challenge with key: %s", e ); + osrfLogInfo( OSRF_LOG_MARK, "Answering s2s challenge with key: %s", e ); osrfChatSendRaw( node, e ); free(d); free(e); node->state = OSRF_CHAT_STATE_S2S_VERIFY; @@ -673,7 +673,7 @@ void osrfChatEndElement( void* blob, const xmlChar* name ) { char* string = xmlDocToString(node->msgDoc, 0 ); char* from = (char*) xmlGetProp(msg, BAD_CAST "from"); - osrfLogDebug( "Routing message to %s\n%s\n", node->to, from, string ); + osrfLogDebug( OSRF_LOG_MARK, "Routing message to %s\n%s\n", node->to, from, string ); osrfChatSend( node->parent, node, node->to, from, string ); xmlFree(from); free(string); @@ -688,12 +688,12 @@ void osrfChatEndElement( void* blob, const xmlChar* name ) { node->remote = va_list_to_string( "%s@%s/%s", node->username, node->domain, node->resource ); - osrfLogInfo("%s successfully logged in", node->remote ); + osrfLogInfo( OSRF_LOG_MARK, "%s successfully logged in", node->remote ); - osrfLogDebug("Setting remote address to %s", node->remote ); + osrfLogDebug( OSRF_LOG_MARK, "Setting remote address to %s", node->remote ); osrfChatSendRaw( node, OSRF_CHAT_LOGIN_OK ); if(osrfHashGet( node->parent->nodeHash, node->remote ) ) { - osrfLogWarning("New node replaces existing node for remote id %s", node->remote); + osrfLogWarning( OSRF_LOG_MARK, "New node replaces existing node for remote id %s", node->remote); osrfHashRemove(node->parent->nodeHash, node->remote); } osrfHashSet( node->parent->nodeHash, node, node->remote ); @@ -709,7 +709,7 @@ void osrfChatHandleCharacter( void* blob, const xmlChar *ch, int len) { osrfChatNode* node = (osrfChatNode*) blob; /* - osrfLogDebug("Char Handler: state %d, xmlstate %d, chardata %s", + osrfLogDebug( OSRF_LOG_MARK, "Char Handler: state %d, xmlstate %d, chardata %s", node->state, node->xmlstate, (char*) ch ); */ @@ -743,9 +743,9 @@ void osrfChatHandleCharacter( void* blob, const xmlChar *ch, int len) { (node->xmlstate & OSRF_CHAT_STATE_INS2SRESULT) ) { char* key = strndup((char*) ch, len); - osrfLogDebug("Got s2s key from %s : %s", node->remote, key ); + osrfLogDebug( OSRF_LOG_MARK, "Got s2s key from %s : %s", node->remote, key ); char* e = osrfChatGenerateS2SKey(node->parent->secret, node->remote, node->authkey ); - osrfLogInfo("\nReceived s2s key from server: %s\nKey should be: %s", key, e ); + osrfLogInfo( OSRF_LOG_MARK, "\nReceived s2s key from server: %s\nKey should be: %s", key, e ); if(eq(key, e)) { char* msg = va_list_to_string(OSRF_CHAT_S2S_VERIFY_REQUEST, @@ -756,7 +756,7 @@ void osrfChatHandleCharacter( void* blob, const xmlChar *ch, int len) { node->xmlstate = 0; } else { - osrfLogWarning("Server2Server keys do not match!"); + osrfLogWarning( OSRF_LOG_MARK, "Server2Server keys do not match!"); } /* do the hash dance again */ diff --git a/src/jserver/osrf_chat_main.c b/src/jserver/osrf_chat_main.c index 99d0195..401d3b4 100644 --- a/src/jserver/osrf_chat_main.c +++ b/src/jserver/osrf_chat_main.c @@ -53,7 +53,7 @@ int main( int argc, char* argv[] ) { osrfChatServer* server = osrfNewChatServer(domain, secret, s2port); if( osrfChatServerConnect( server, port, s2port, listenaddr ) != 0 ) { - osrfLogError("ChopChop unable to bind to port %d on %s", port, listenaddr); + osrfLogError( OSRF_LOG_MARK, "ChopChop unable to bind to port %d on %s", port, listenaddr); return -1; } diff --git a/src/libstack/osrfConfig.c b/src/libstack/osrfConfig.c index ce4beec..d25f631 100644 --- a/src/libstack/osrfConfig.c +++ b/src/libstack/osrfConfig.c @@ -45,7 +45,7 @@ osrfConfig* osrfConfigInit(char* configFile, char* configContext) { xmlDocPtr doc = xmlParseFile(configFile); if(!doc) { - osrfLogWarning( "Unable to parse XML config file %s", configFile); + osrfLogWarning( OSRF_LOG_MARK, "Unable to parse XML config file %s", configFile); return NULL; } @@ -53,7 +53,7 @@ osrfConfig* osrfConfigInit(char* configFile, char* configContext) { xmlFreeDoc(doc); if(!cfg->config) { - osrfLogWarning("xmlDocToJSON failed for config %s", configFile); + osrfLogWarning( OSRF_LOG_MARK, "xmlDocToJSON failed for config %s", configFile); return NULL; } @@ -64,7 +64,7 @@ char* osrfConfigGetValue(osrfConfig* cfg, char* path, ...) { if(!path) return NULL; if(!cfg) cfg = __osrfConfigDefault; - if(!cfg) { osrfLogWarning("No Confif object!"); return NULL; } + if(!cfg) { osrfLogWarning( OSRF_LOG_MARK, "No Confif object!"); return NULL; } VA_LIST_TO_STRING(path); @@ -89,7 +89,7 @@ int osrfConfigGetValueList(osrfConfig* cfg, osrfStringArray* arr, char* path, .. if(!arr || !path) return 0; if(!cfg) cfg = __osrfConfigDefault; - if(!cfg) { osrfLogWarning("No Config object!"); return -1;} + if(!cfg) { osrfLogWarning( OSRF_LOG_MARK, "No Config object!"); return -1;} VA_LIST_TO_STRING(path); diff --git a/src/libstack/osrf_app_session.c b/src/libstack/osrf_app_session.c index d3b25bb..5338a36 100644 --- a/src/libstack/osrf_app_session.c +++ b/src/libstack/osrf_app_session.c @@ -50,7 +50,7 @@ void _osrf_app_request_free( void * req ){ /** Pushes the given message onto the list of 'responses' to this request */ void _osrf_app_request_push_queue( osrf_app_request* req, osrf_message* result ){ if(req == NULL || result == NULL) return; - osrfLogDebug( "App Session pushing request [%d] onto request queue", result->thread_trace ); + osrfLogDebug( OSRF_LOG_MARK, "App Session pushing request [%d] onto request queue", result->thread_trace ); if(req->result == NULL) req->result = result; else { @@ -72,7 +72,7 @@ void osrf_app_session_request_finish( void osrf_app_session_request_reset_timeout( osrf_app_session* session, int req_id ) { if(session == NULL) return; - osrfLogDebug("Resetting request timeout %d", req_id ); + osrfLogDebug( OSRF_LOG_MARK, "Resetting request timeout %d", req_id ); osrf_app_request* req = osrfListGetIndex( session->request_queue, req_id ); if(req == NULL) return; req->reset_timeout = 1; @@ -99,13 +99,13 @@ osrf_message* _osrf_app_request_recv( osrf_app_request* req, int timeout ) { while( remaining >= 0 ) { /* tell the session to wait for stuff */ - osrfLogDebug( "In app_request receive with remaining time [%d]", (int) remaining ); + osrfLogDebug( OSRF_LOG_MARK, "In app_request receive with remaining time [%d]", (int) remaining ); osrf_app_session_queue_wait( req->session, 0 ); if( req->result != NULL ) { /* if we received anything */ /* pop off the first message in the list */ - osrfLogDebug( "app_request_recv received a message, returning it"); + osrfLogDebug( OSRF_LOG_MARK, "app_request_recv received a message, returning it"); osrf_message* ret_msg = req->result; osrf_message* tmp_msg = ret_msg->next; req->result = tmp_msg; @@ -119,7 +119,7 @@ osrf_message* _osrf_app_request_recv( osrf_app_request* req, int timeout ) { if( req->result != NULL ) { /* if we received anything */ /* pop off the first message in the list */ - osrfLogDebug( "app_request_recv received a message, returning it"); + osrfLogDebug( OSRF_LOG_MARK, "app_request_recv received a message, returning it"); osrf_message* ret_msg = req->result; osrf_message* tmp_msg = ret_msg->next; req->result = tmp_msg; @@ -131,13 +131,13 @@ osrf_message* _osrf_app_request_recv( osrf_app_request* req, int timeout ) { if(req->reset_timeout) { remaining = (time_t) timeout; req->reset_timeout = 0; - osrfLogDebug("Recevied a timeout reset"); + osrfLogDebug( OSRF_LOG_MARK, "Recevied a timeout reset"); } else { remaining -= (int) (time(NULL) - start); } } - osrfLogDebug("Returning NULL from app_request_recv after timeout"); + osrfLogDebug( OSRF_LOG_MARK, "Returning NULL from app_request_recv after timeout"); return NULL; } @@ -145,7 +145,7 @@ osrf_message* _osrf_app_request_recv( osrf_app_request* req, int timeout ) { int _osrf_app_request_resend( osrf_app_request* req ) { if(req == NULL) return 0; if(!req->complete) { - osrfLogDebug( "Resending request [%d]", req->request_id ); + osrfLogDebug( OSRF_LOG_MARK, "Resending request [%d]", req->request_id ); return _osrf_app_session_send( req->session, req->payload ); } return 1; @@ -185,7 +185,7 @@ osrf_app_session* osrf_app_client_session_init( char* remote_service ) { session->transport_handle = osrf_system_get_transport_client(); if( session->transport_handle == NULL ) { - osrfLogWarning("No transport client for service 'client'"); + osrfLogWarning( OSRF_LOG_MARK, "No transport client for service 'client'"); return NULL; } @@ -210,10 +210,10 @@ osrf_app_session* osrf_app_client_session_init( char* remote_service ) { #ifdef ASSUME_STATELESS session->stateless = 1; - osrfLogDebug("%s session is stateless", remote_service ); + osrfLogDebug( OSRF_LOG_MARK, "%s session is stateless", remote_service ); #else session->stateless = 0; - osrfLogDebug("%s session is NOT stateless", remote_service ); + osrfLogDebug( OSRF_LOG_MARK, "%s session is NOT stateless", remote_service ); #endif /* build a chunky, random session id */ @@ -222,7 +222,7 @@ osrf_app_session* osrf_app_client_session_init( char* remote_service ) { sprintf(id, "%lf.%d%d", get_timestamp_millis(), (int)time(NULL), getpid()); session->session_id = strdup(id); - osrfLogDebug( "Building a new client session with id [%s] [%s]", + osrfLogDebug( OSRF_LOG_MARK, "Building a new client session with id [%s] [%s]", session->remote_service, session->session_id ); session->thread_trace = 0; @@ -236,7 +236,7 @@ osrf_app_session* osrf_app_client_session_init( char* remote_service ) { osrf_app_session* osrf_app_server_session_init( char* session_id, char* our_app, char* remote_id ) { - osrfLogInfo("Initing server session with session id %s, service %s," + osrfLogInfo( OSRF_LOG_MARK, "Initing server session with session id %s, service %s," " and remote_id %s", session_id, our_app, remote_id ); osrf_app_session* session = osrf_app_session_find_session( session_id ); @@ -246,7 +246,7 @@ osrf_app_session* osrf_app_server_session_init( session->transport_handle = osrf_system_get_transport_client(); if( session->transport_handle == NULL ) { - osrfLogWarning("No transport client for service '%s'", our_app ); + osrfLogWarning( OSRF_LOG_MARK, "No transport client for service '%s'", our_app ); return NULL; } @@ -323,11 +323,11 @@ int osrf_app_session_make_req( osrf_app_request* req = _osrf_app_request_init( session, req_msg ); if(_osrf_app_session_send( session, req_msg ) ) { - osrfLogWarning( "Error sending request message [%d]", session->thread_trace ); + osrfLogWarning( OSRF_LOG_MARK, "Error sending request message [%d]", session->thread_trace ); return -1; } - osrfLogDebug( "Pushing [%d] onto requeust queue for session [%s] [%s]", + osrfLogDebug( OSRF_LOG_MARK, "Pushing [%d] onto requeust queue for session [%s] [%s]", req->request_id, session->remote_service, session->session_id ); osrfListSet( session->request_queue, req, req->request_id ); return req->request_id; @@ -357,7 +357,7 @@ void osrf_app_session_reset_remote( osrf_app_session* session ){ return; free(session->remote_id); - osrfLogDebug( "App Session [%s] [%s] resetting remote id to %s", + osrfLogDebug( OSRF_LOG_MARK, "App Session [%s] [%s] resetting remote id to %s", session->remote_service, session->session_id, session->orig_remote_id ); session->remote_id = strdup(session->orig_remote_id); @@ -396,7 +396,7 @@ int osrf_app_session_connect(osrf_app_session* session){ int timeout = 5; /* XXX CONFIG VALUE */ - osrfLogDebug( "AppSession connecting to %s", session->remote_id ); + osrfLogDebug( OSRF_LOG_MARK, "AppSession connecting to %s", session->remote_id ); /* defaulting to protocol 1 for now */ osrf_message* con_msg = osrf_message_init( CONNECT, session->thread_trace, 1 ); @@ -415,7 +415,7 @@ int osrf_app_session_connect(osrf_app_session* session){ } if(session->state == OSRF_SESSION_CONNECTED) - osrfLogDebug(" * Connected Successfully to %s", session->remote_service ); + osrfLogDebug( OSRF_LOG_MARK, " * Connected Successfully to %s", session->remote_service ); if(session->state != OSRF_SESSION_CONNECTED) return 0; @@ -434,13 +434,13 @@ int osrf_app_session_disconnect( osrf_app_session* session){ return 1; if(session->stateless && session->state != OSRF_SESSION_CONNECTED) { - osrfLogDebug( + osrfLogDebug( OSRF_LOG_MARK, "Exiting disconnect on stateless session %s", session->session_id); return 1; } - osrfLogDebug( "AppSession disconnecting from %s", session->remote_id ); + osrfLogDebug(OSRF_LOG_MARK, "AppSession disconnecting from %s", session->remote_id ); osrf_message* dis_msg = osrf_message_init( DISCONNECT, session->thread_trace, 1 ); session->state = OSRF_SESSION_DISCONNECTED; @@ -491,7 +491,7 @@ int osrfAppSessionSendBatch( osrfAppSession* session, osrf_message* msgs[], int transport_message* t_msg = message_init( string, "", session->session_id, session->remote_id, NULL ); - osrfLogDebug("Session [%s] [%s] sending to %s \nData: %s", + osrfLogDebug(OSRF_LOG_MARK, "Session [%s] [%s] sending to %s \nData: %s", session->remote_service, session->session_id, t_msg->recipient, string ); retval = client_send_message( session->transport_handle, t_msg ); @@ -524,7 +524,7 @@ int _osrf_app_session_send( osrf_app_session* session, osrf_message* msg ){ int osrf_app_session_queue_wait( osrf_app_session* session, int timeout ){ if(session == NULL) return 0; int ret_val = 0; - osrfLogDebug( "AppSession in queue_wait with timeout %d", timeout ); + osrfLogDebug(OSRF_LOG_MARK, "AppSession in queue_wait with timeout %d", timeout ); ret_val = osrf_stack_entry_point(session->transport_handle, timeout); return ret_val; } @@ -540,7 +540,7 @@ void osrfAppSessionFree( osrfAppSession* ses ) { void osrf_app_session_destroy( osrf_app_session* session ){ if(session == NULL) return; - osrfLogDebug( "AppSession [%s] [%s] destroying self and deleting requests", + osrfLogDebug(OSRF_LOG_MARK, "AppSession [%s] [%s] destroying self and deleting requests", session->remote_service, session->session_id ); if(session->type == OSRF_SESSION_CLIENT && session->state != OSRF_SESSION_DISCONNECTED ) { /* disconnect if we're a client */ diff --git a/src/libstack/osrf_application.c b/src/libstack/osrf_application.c index 5a47d49..f75451a 100644 --- a/src/libstack/osrf_application.c +++ b/src/libstack/osrf_application.c @@ -12,13 +12,13 @@ int osrfAppRegisterApplication( char* appName, char* soFile ) { if(!__osrfAppHash) __osrfAppHash = osrfNewHash(); - osrfLogInfo("Registering application %s with file %s", appName, soFile ); + osrfLogInfo( OSRF_LOG_MARK, "Registering application %s with file %s", appName, soFile ); osrfApplication* app = safe_malloc(sizeof(osrfApplication)); app->handle = dlopen (soFile, RTLD_NOW); if(!app->handle) { - osrfLogWarning("Failed to dlopen library file %s: %s", soFile, dlerror() ); + osrfLogWarning( OSRF_LOG_MARK, "Failed to dlopen library file %s: %s", soFile, dlerror() ); dlerror(); /* clear the error */ free(app); return -1; @@ -32,14 +32,14 @@ int osrfAppRegisterApplication( char* appName, char* soFile ) { *(void **) (&init) = dlsym(app->handle, "osrfAppInitialize"); if( (error = dlerror()) != NULL ) { - osrfLogWarning("! Unable to locate method symbol [osrfAppInitialize] for app %s: %s", appName, error ); + osrfLogWarning( OSRF_LOG_MARK, "! Unable to locate method symbol [osrfAppInitialize] for app %s: %s", appName, error ); } else { /* run the method */ int ret; if( (ret = (*init)()) ) { - osrfLogWarning("Application %s returned non-zero value from " + osrfLogWarning( OSRF_LOG_MARK, "Application %s returned non-zero value from " "'osrfAppInitialize', not registering...", appName ); //free(app->name); /* need a method to remove an application from the list */ //free(app); @@ -49,7 +49,7 @@ int osrfAppRegisterApplication( char* appName, char* soFile ) { __osrfAppRegisterSysMethods(appName); - osrfLogInfo("Application %s registered successfully", appName ); + osrfLogInfo( OSRF_LOG_MARK, "Application %s registered successfully", appName ); osrfLogSetAppname(appName); @@ -64,11 +64,11 @@ int osrfAppRegisterMethod( char* appName, char* methodName, osrfApplication* app = _osrfAppFindApplication(appName); if(!app) { - osrfLogWarning("Unable to locate application %s", appName ); + osrfLogWarning( OSRF_LOG_MARK, "Unable to locate application %s", appName ); return -1; } - osrfLogDebug("Registering method %s for app %s", methodName, appName ); + osrfLogDebug( OSRF_LOG_MARK, "Registering method %s for app %s", methodName, appName ); osrfMethod* method = _osrfAppBuildMethod( methodName, symbolName, notes, argc, options ); @@ -168,7 +168,7 @@ int osrfAppRunMethod( char* appName, char* methodName, /* this is the method we're gonna run */ int (*meth) (osrfMethodContext*); - osrfLogInfo("Running method [%s] for app [%s] with request id %d and " + osrfLogInfo( OSRF_LOG_MARK, "Running method [%s] for app [%s] with request id %d and " "thread trace %s", methodName, appName, reqId, ses->session_id ); if( !(app = _osrfAppFindApplication(appName)) ) @@ -228,7 +228,7 @@ int _osrfAppRespond( osrfMethodContext* ctx, jsonObject* data, int complete ) { if(!(ctx && ctx->method)) return -1; if( ctx->method->options & OSRF_METHOD_ATOMIC ) { - osrfLogDebug( + osrfLogDebug( OSRF_LOG_MARK, "Adding responses to stash for atomic method %s", ctx->method ); if( ctx->responses == NULL ) @@ -256,7 +256,7 @@ int _osrfAppRespond( osrfMethodContext* ctx, jsonObject* data, int complete ) { int __osrfAppPostProcess( osrfMethodContext* ctx, int retcode ) { if(!(ctx && ctx->method)) return -1; - osrfLogDebug( "Postprocessing method %s with retcode %d", + osrfLogDebug( OSRF_LOG_MARK, "Postprocessing method %s with retcode %d", ctx->method->name, retcode ); if(ctx->responses) { /* we have cached responses to return (no responses have been sent) */ @@ -280,7 +280,7 @@ int osrfAppRequestRespondException( osrfAppSession* ses, int request, char* msg, if(!ses) return -1; if(!msg) msg = ""; VA_LIST_TO_STRING(msg); - osrfLogWarning( "Returning method exception with message: %s", VA_BUF ); + osrfLogWarning( OSRF_LOG_MARK, "Returning method exception with message: %s", VA_BUF ); osrfAppSessionStatus( ses, OSRF_STATUS_NOTFOUND, "osrfMethodException", request, VA_BUF ); return 0; } diff --git a/src/libstack/osrf_application.h b/src/libstack/osrf_application.h index 51f9867..9747630 100644 --- a/src/libstack/osrf_application.h +++ b/src/libstack/osrf_application.h @@ -24,20 +24,20 @@ This macro verifies methods receive the correct parameters */ #define _OSRF_METHOD_VERIFY_CONTEXT(d) \ if(!d) return -1; \ - if(!d->session) { osrfLogError( "Session is NULL in app reqeust" ); return -1; }\ - if(!d->method) { osrfLogError( "Method is NULL in app reqeust" ); return -1; }\ - if(!d->params) { osrfLogError( "Params is NULL in app reqeust %s", d->method->name ); return -1; }\ + if(!d->session) { osrfLogError( OSRF_LOG_MARK, "Session is NULL in app reqeust" ); return -1; }\ + if(!d->method) { osrfLogError( OSRF_LOG_MARK, "Method is NULL in app reqeust" ); return -1; }\ + if(!d->params) { osrfLogError( OSRF_LOG_MARK, "Params is NULL in app reqeust %s", d->method->name ); return -1; }\ if( d->params->type != JSON_ARRAY ) { \ - osrfLogError( "'params' is not a JSON array for method %s", d->method->name);\ + osrfLogError( OSRF_LOG_MARK, "'params' is not a JSON array for method %s", d->method->name);\ return -1; }\ - if( !d->method->name ) { osrfLogError( "Method name is NULL"); return -1; } + if( !d->method->name ) { osrfLogError( OSRF_LOG_MARK, "Method name is NULL"); return -1; } #ifdef OSRF_LOG_PARAMS #define OSRF_METHOD_VERIFY_CONTEXT(d) \ _OSRF_METHOD_VERIFY_CONTEXT(d); \ char* __j = jsonObjectToJSON(d->params);\ if(__j) { \ - osrfLogInfo( "%s %s - %s", d->session->remote_service, d->method->name, __j);\ + osrfLogInfo( OSRF_LOG_MARK, "%s %s - %s", d->session->remote_service, d->method->name, __j);\ free(__j); \ } #else @@ -50,8 +50,8 @@ #define OSRF_METHOD_VERIFY_DESCRIPTION(app, d) \ if(!app) return -1; \ if(!d) return -1;\ - if(!d->name) { osrfLogError( "No method name provided in description" ), return -1; } \ - if(!d->symbol) { osrfLogError( "No method symbol provided in description" ), return -1; } \ + if(!d->name) { osrfLogError( OSRF_LOG_MARK, "No method name provided in description" ), return -1; } \ + if(!d->symbol) { osrfLogError( OSRF_LOG_MARK, "No method symbol provided in description" ), return -1; } \ if(!d->notes) d->notes = ""; \ if(!d->paramNotes) d->paramNotes = "";\ if(!d->returnNotes) d->returnNotes = ""; diff --git a/src/libstack/osrf_cache.c b/src/libstack/osrf_cache.c index a63c431..ff8940d 100644 --- a/src/libstack/osrf_cache.c +++ b/src/libstack/osrf_cache.c @@ -34,7 +34,7 @@ int osrfCacheInit( char* serverStrings[], int size, time_t maxCacheSeconds ) { int osrfCachePutObject( char* key, const jsonObject* obj, time_t seconds ) { if( !(key && obj) ) return -1; char* s = jsonObjectToJSON( obj ); - osrfLogInternal("osrfCachePut(): Putting object: %s", s); + osrfLogInternal( OSRF_LOG_MARK, "osrfCachePut(): Putting object: %s", s); if( seconds < 0 ) seconds = __osrfCacheMaxSeconds; mc_set(__osrfCache, key, strlen(key), s, strlen(s), seconds, 0); @@ -45,7 +45,7 @@ int osrfCachePutObject( char* key, const jsonObject* obj, time_t seconds ) { int osrfCachePutString( char* key, const char* value, time_t seconds ) { if( !(key && value) ) return -1; if( seconds < 0 ) seconds = __osrfCacheMaxSeconds; - osrfLogInternal("osrfCachePutString(): Putting string: %s", value); + osrfLogInternal( OSRF_LOG_MARK, "osrfCachePutString(): Putting string: %s", value); mc_set(__osrfCache, key, strlen(key), value, strlen(value), seconds, 0); return 0; } @@ -56,7 +56,7 @@ jsonObject* osrfCacheGetObject( char* key, ... ) { VA_LIST_TO_STRING(key); char* data = (char*) mc_aget( __osrfCache, VA_BUF, strlen(VA_BUF) ); if( data ) { - osrfLogInternal("osrfCacheGetObject(): Returning object: %s", data); + osrfLogInternal( OSRF_LOG_MARK, "osrfCacheGetObject(): Returning object: %s", data); obj = jsonParseString( data ); return obj; } @@ -68,7 +68,7 @@ char* osrfCacheGetString( char* key, ... ) { if( key ) { VA_LIST_TO_STRING(key); char* data = (char*) mc_aget(__osrfCache, VA_BUF, strlen(VA_BUF) ); - osrfLogInternal("osrfCacheGetObject(): Returning object: %s", data); + osrfLogInternal( OSRF_LOG_MARK, "osrfCacheGetObject(): Returning object: %s", data); return data; } return NULL; diff --git a/src/libstack/osrf_message.c b/src/libstack/osrf_message.c index d7b9dde..14452bf 100644 --- a/src/libstack/osrf_message.c +++ b/src/libstack/osrf_message.c @@ -34,7 +34,7 @@ void osrf_message_set_params( osrf_message* msg, jsonObject* o ) { if(!msg || !o) return; if(o->type != JSON_ARRAY) { - osrfLogWarning("passing non-array to osrf_message_set_params(), fixing..."); + osrfLogWarning( OSRF_LOG_MARK, "passing non-array to osrf_message_set_params(), fixing..."); jsonObject* clone = jsonObjectClone(o); o = jsonNewObject(NULL); jsonObjectPush(o, clone); @@ -214,7 +214,7 @@ int osrf_message_deserialize(char* string, osrf_message* msgs[], int count) { jsonObject* json = jsonParseString(string); if(!json) { - osrfLogWarning( + osrfLogWarning( OSRF_LOG_MARK, "osrf_message_deserialize() unable to parse data: \n%s\n", string); return 0; } diff --git a/src/libstack/osrf_prefork.c b/src/libstack/osrf_prefork.c index c467ae9..d2b0168 100644 --- a/src/libstack/osrf_prefork.c +++ b/src/libstack/osrf_prefork.c @@ -12,7 +12,7 @@ void sigchld_handler( int sig ); int osrf_prefork_run(char* appname) { if(!appname) { - osrfLogError("osrf_prefork_run requires an appname to run!"); + osrfLogError( OSRF_LOG_MARK, "osrf_prefork_run requires an appname to run!"); return -1; } @@ -22,20 +22,20 @@ int osrf_prefork_run(char* appname) { int maxc = 10; int minc = 3; - osrfLogInfo("Loading config in osrf_forker for app %s", appname); + osrfLogInfo( OSRF_LOG_MARK, "Loading config in osrf_forker for app %s", appname); jsonObject* max_req = osrf_settings_host_value_object("/apps/%s/unix_config/max_requests", appname); jsonObject* min_children = osrf_settings_host_value_object("/apps/%s/unix_config/min_children", appname); jsonObject* max_children = osrf_settings_host_value_object("/apps/%s/unix_config/max_children", appname); - if(!max_req) osrfLogWarning("Max requests not defined, assuming 1000"); + if(!max_req) osrfLogWarning( OSRF_LOG_MARK, "Max requests not defined, assuming 1000"); else maxr = (int) jsonObjectGetNumber(max_req); - if(!min_children) osrfLogWarning("Min children not defined, assuming 3"); + if(!min_children) osrfLogWarning( OSRF_LOG_MARK, "Min children not defined, assuming 3"); else minc = (int) jsonObjectGetNumber(min_children); - if(!max_children) osrfLogWarning("Max children not defined, assuming 10"); + if(!max_children) osrfLogWarning( OSRF_LOG_MARK, "Max children not defined, assuming 10"); else maxc = (int) jsonObjectGetNumber(max_children); jsonObjectFree(max_req); @@ -46,7 +46,7 @@ int osrf_prefork_run(char* appname) { char* resc = va_list_to_string("%s_listener", appname); if(!osrf_system_bootstrap_client_resc( NULL, NULL, resc )) { - osrfLogError("Unable to bootstrap client for osrf_prefork_run()"); + osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap client for osrf_prefork_run()"); free(resc); return -1; } @@ -59,7 +59,7 @@ int osrf_prefork_run(char* appname) { forker->appname = strdup(appname); if(forker == NULL) { - osrfLogError("osrf_prefork_run() failed to create prefork_simple object"); + osrfLogError( OSRF_LOG_MARK, "osrf_prefork_run() failed to create prefork_simple object"); return -1; } @@ -67,10 +67,10 @@ int osrf_prefork_run(char* appname) { osrf_prefork_register_routers(appname); - osrfLogInfo("Launching osrf_forker for app %s", appname); + osrfLogInfo( OSRF_LOG_MARK, "Launching osrf_forker for app %s", appname); prefork_run(forker); - osrfLogWarning("prefork_run() retuned - how??"); + osrfLogWarning( OSRF_LOG_MARK, "prefork_run() retuned - how??"); prefork_free(forker); return 0; @@ -84,14 +84,14 @@ void osrf_prefork_register_routers( char* appname ) { char* routerName = osrfConfigGetValue( NULL, "/router_name" ); transport_client* client = osrfSystemGetTransportClient(); - osrfLogInfo("router name is %s and we have %d routers to connect to", routerName, c ); + osrfLogInfo( OSRF_LOG_MARK, "router name is %s and we have %d routers to connect to", routerName, c ); while( c ) { char* domain = osrfStringArrayGetString(arr, --c); if(domain) { char* jid = va_list_to_string( "%s@%s/router", routerName, domain ); - osrfLogInfo("Registering with router %s", jid ); + osrfLogInfo( OSRF_LOG_MARK, "Registering with router %s", jid ); transport_message* msg = message_init("registering", NULL, NULL, jid, NULL ); message_set_router_info( msg, NULL, NULL, appname, "register", 0 ); @@ -109,11 +109,11 @@ void osrf_prefork_register_routers( char* appname ) { void prefork_child_init_hook(prefork_child* child) { if(!child) return; - osrfLogDebug("Child init hook for child %d", child->pid); + osrfLogDebug( OSRF_LOG_MARK, "Child init hook for child %d", child->pid); char* resc = va_list_to_string("%s_drone",child->appname); if(!osrf_system_bootstrap_client_resc( NULL, NULL, resc)) { - osrfLogError("Unable to bootstrap client for osrf_prefork_run()"); + osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap client for osrf_prefork_run()"); free(resc); return; } @@ -139,7 +139,7 @@ void prefork_child_process_request(prefork_child* child, char* data) { /* keepalive loop for stateful sessions */ - osrfLogDebug("Entering keepalive loop for session %s", session->session_id ); + osrfLogDebug( OSRF_LOG_MARK, "Entering keepalive loop for session %s", session->session_id ); } @@ -147,13 +147,13 @@ prefork_simple* prefork_simple_init( transport_client* client, int max_requests, int min_children, int max_children ) { if( min_children > max_children ) { - osrfLogError( "min_children (%d) is greater " + osrfLogError( OSRF_LOG_MARK, "min_children (%d) is greater " "than max_children (%d)", min_children, max_children ); return NULL; } if( max_children > ABS_MAX_CHILDREN ) { - osrfLogError( "max_children (%d) is greater than ABS_MAX_CHILDREN (%d)", + osrfLogError( OSRF_LOG_MARK, "max_children (%d) is greater than ABS_MAX_CHILDREN (%d)", max_children, ABS_MAX_CHILDREN ); return NULL; } @@ -177,16 +177,16 @@ prefork_child* launch_child( prefork_simple* forker ) { /* Set up the data pipes and add the child struct to the parent */ if( pipe(data_fd) < 0 ) { /* build the data pipe*/ - osrfLogError( "Pipe making error" ); + osrfLogError( OSRF_LOG_MARK, "Pipe making error" ); return NULL; } if( pipe(status_fd) < 0 ) {/* build the status pipe */ - osrfLogError( "Pipe making error" ); + osrfLogError( OSRF_LOG_MARK, "Pipe making error" ); return NULL; } - osrfLogInternal( "Pipes: %d %d %d %d", data_fd[0], data_fd[1], status_fd[0], status_fd[1] ); + osrfLogInternal( OSRF_LOG_MARK, "Pipes: %d %d %d %d", data_fd[0], data_fd[1], status_fd[0], status_fd[1] ); prefork_child* child = prefork_child_init( forker->max_requests, data_fd[0], data_fd[1], status_fd[0], status_fd[1] ); @@ -196,7 +196,7 @@ prefork_child* launch_child( prefork_simple* forker ) { add_prefork_child( forker, child ); if( (pid=fork()) < 0 ) { - osrfLogError( "Forking Error" ); + osrfLogError( OSRF_LOG_MARK, "Forking Error" ); return NULL; } @@ -206,7 +206,7 @@ prefork_child* launch_child( prefork_simple* forker ) { (forker->current_num_children)++; child->pid = pid; - osrfLogDebug( "Parent launched %d", pid ); + osrfLogDebug( OSRF_LOG_MARK, "Parent launched %d", pid ); /* *no* child pipe FD's can be closed or the parent will re-use fd's that the children are currently using */ return child; @@ -214,7 +214,7 @@ prefork_child* launch_child( prefork_simple* forker ) { else { /* child */ - osrfLogInternal("I am new child with read_data_fd = %d and write_status_fd = %d", + osrfLogInternal( OSRF_LOG_MARK, "I am new child with read_data_fd = %d and write_status_fd = %d", child->read_data_fd, child->write_status_fd ); child->pid = getpid(); @@ -271,11 +271,11 @@ void prefork_run(prefork_simple* forker) { while(1) { if( forker->first_child == NULL ) {/* no more children */ - osrfLogWarning("No more children..." ); + osrfLogWarning( OSRF_LOG_MARK, "No more children..." ); return; } - osrfLogDebug("Forker going into wait for data..."); + osrfLogDebug( OSRF_LOG_MARK, "Forker going into wait for data..."); cur_msg = client_recv( forker->connection, -1 ); //fprintf(stderr, "Got Data %f\n", get_timestamp_millis() ); @@ -288,30 +288,30 @@ void prefork_run(prefork_simple* forker) { check_children( forker ); - osrfLogDebug( "Server received inbound data" ); + osrfLogDebug( OSRF_LOG_MARK, "Server received inbound data" ); int k; prefork_child* cur_child = forker->first_child; /* Look for an available child */ for( k = 0; k < forker->current_num_children; k++ ) { - osrfLogInternal("Searching for available child. cur_child->pid = %d", cur_child->pid ); - osrfLogInternal("Current num children %d and loop %d", forker->current_num_children, k); + osrfLogInternal( OSRF_LOG_MARK, "Searching for available child. cur_child->pid = %d", cur_child->pid ); + osrfLogInternal( OSRF_LOG_MARK, "Current num children %d and loop %d", forker->current_num_children, k); if( cur_child->available ) { - osrfLogDebug( "forker sending data to %d", cur_child->pid ); + osrfLogDebug( OSRF_LOG_MARK, "forker sending data to %d", cur_child->pid ); message_prepare_xml( cur_msg ); char* data = cur_msg->msg_xml; if( ! data || strlen(data) < 1 ) break; cur_child->available = 0; - osrfLogInternal( "Writing to child fd %d", cur_child->write_data_fd ); + osrfLogInternal( OSRF_LOG_MARK, "Writing to child fd %d", cur_child->write_data_fd ); int written = 0; //fprintf(stderr, "Writing Data %f\n", get_timestamp_millis() ); if( (written = write( cur_child->write_data_fd, data, strlen(data) + 1 )) < 0 ) { - osrfLogWarning("Write returned error %d", errno); + osrfLogWarning( OSRF_LOG_MARK, "Write returned error %d", errno); cur_child = cur_child->next; continue; } @@ -327,9 +327,9 @@ void prefork_run(prefork_simple* forker) { /* if none available, add a new child if we can */ if( ! honored ) { - osrfLogDebug("Not enough children, attempting to add..."); + osrfLogDebug( OSRF_LOG_MARK, "Not enough children, attempting to add..."); if( forker->current_num_children < forker->max_children ) { - osrfLogDebug( "Launching new child with current_num = %d", + osrfLogDebug( OSRF_LOG_MARK, "Launching new child with current_num = %d", forker->current_num_children ); prefork_child* new_child = launch_child( forker ); @@ -337,7 +337,7 @@ void prefork_run(prefork_simple* forker) { char* data = cur_msg->msg_xml; if( ! data || strlen(data) < 1 ) break; new_child->available = 0; - osrfLogDebug( "Writing to new child fd %d : pid %d", + osrfLogDebug( OSRF_LOG_MARK, "Writing to new child fd %d : pid %d", new_child->write_data_fd, new_child->pid ); write( new_child->write_data_fd, data, strlen(data) + 1 ); forker->first_child = new_child->next; @@ -346,7 +346,7 @@ void prefork_run(prefork_simple* forker) { } if( !honored ) { - osrfLogWarning( "No children available, sleeping and looping..." ); + osrfLogWarning( OSRF_LOG_MARK, "No children available, sleeping and looping..." ); usleep( 50000 ); /* 50 milliseconds */ } @@ -396,7 +396,7 @@ void check_children( prefork_simple* forker ) { FD_CLR(0,&read_set);/* just to be sure */ if( (select_ret=select( max_fd + 1 , &read_set, NULL, NULL, &tv)) == -1 ) { - osrfLogWarning( "Select returned error %d on check_children", errno ); + osrfLogWarning( OSRF_LOG_MARK, "Select returned error %d on check_children", errno ); } if( select_ret == 0 ) @@ -410,7 +410,7 @@ void check_children( prefork_simple* forker ) { if( FD_ISSET( cur_child->read_status_fd, &read_set ) ) { //printf( "Server received status from a child %d\n", cur_child->pid ); - osrfLogDebug( "Server received status from a child %d", cur_child->pid ); + osrfLogDebug( OSRF_LOG_MARK, "Server received status from a child %d", cur_child->pid ); num_handled++; @@ -418,10 +418,10 @@ void check_children( prefork_simple* forker ) { char buf[64]; memset( buf, 0, 64); if( (n=read(cur_child->read_status_fd, buf, 63)) < 0 ) { - osrfLogWarning("Read error afer select in child status read with errno %d", errno); + osrfLogWarning( OSRF_LOG_MARK, "Read error afer select in child status read with errno %d", errno); } - osrfLogDebug( "Read %d bytes from status buffer: %s", n, buf ); + osrfLogDebug( OSRF_LOG_MARK, "Read %d bytes from status buffer: %s", n, buf ); cur_child->available = 1; } cur_child = cur_child->next; @@ -462,7 +462,7 @@ void prefork_child_wait( prefork_child* child ) { } if( n < 0 ) { - osrfLogWarning( "Child read returned error with errno %d", errno ); + osrfLogWarning( OSRF_LOG_MARK, "Child read returned error with errno %d", errno ); break; } @@ -472,7 +472,7 @@ void prefork_child_wait( prefork_child* child ) { buffer_free(gbuf); - osrfLogDebug("Child exiting...[%d]", getpid() ); + osrfLogDebug( OSRF_LOG_MARK, "Child exiting...[%d]", getpid() ); exit(0); } @@ -524,7 +524,7 @@ void del_prefork_child( prefork_simple* forker, pid_t pid ) { if( forker->first_child == NULL ) { return; } (forker->current_num_children)--; - osrfLogDebug("Deleting Child: %d", pid ); + osrfLogDebug( OSRF_LOG_MARK, "Deleting Child: %d", pid ); prefork_child* start_child = forker->first_child; /* starting point */ prefork_child* cur_child = start_child; /* current pointer */ @@ -609,7 +609,7 @@ prefork_child* prefork_child_init( int prefork_free( prefork_simple* prefork ) { while( prefork->first_child != NULL ) { - osrfLogInfo( "Killing children and sleeping 1 to reap..." ); + osrfLogInfo( OSRF_LOG_MARK, "Killing children and sleeping 1 to reap..." ); kill( 0, SIGKILL ); sleep(1); } diff --git a/src/libstack/osrf_settings.c b/src/libstack/osrf_settings.c index fc32438..96127d9 100644 --- a/src/libstack/osrf_settings.c +++ b/src/libstack/osrf_settings.c @@ -38,7 +38,7 @@ int osrf_settings_retrieve(char* hostname) { osrf_app_session_destroy( session ); if(!config) { - osrfLogError("Unable to load config for host %s", hostname); + osrfLogError( OSRF_LOG_MARK, "Unable to load config for host %s", hostname); return -1; } } diff --git a/src/libstack/osrf_stack.c b/src/libstack/osrf_stack.c index cbd8289..1c2e4c8 100644 --- a/src/libstack/osrf_stack.c +++ b/src/libstack/osrf_stack.c @@ -12,7 +12,7 @@ int osrf_stack_process( transport_client* client, int timeout ) { transport_message* msg = NULL; while( (msg = client_recv( client, timeout )) ) { - osrfLogDebug( "Received message from transport code from %s", msg->sender ); + osrfLogDebug( OSRF_LOG_MARK, "Received message from transport code from %s", msg->sender ); osrf_stack_transport_handler( msg, NULL ); timeout = 0; } @@ -29,17 +29,17 @@ osrfAppSession* osrf_stack_transport_handler( transport_message* msg, char* my_s if(!msg) return NULL; - osrfLogDebug( "Transport handler received new message \nfrom %s " + osrfLogDebug( OSRF_LOG_MARK, "Transport handler received new message \nfrom %s " "to %s with body \n\n%s\n", msg->sender, msg->recipient, msg->body ); if( msg->is_error && ! msg->thread ) { - osrfLogWarning("!! Received jabber layer error for %s ... exiting\n", msg->sender ); + osrfLogWarning( OSRF_LOG_MARK, "!! Received jabber layer error for %s ... exiting\n", msg->sender ); message_free( msg ); return NULL; } if(! msg->thread && ! msg->is_error ) { - osrfLogWarning("Received a non-error message with no thread trace... dropping"); + osrfLogWarning( OSRF_LOG_MARK, "Received a non-error message with no thread trace... dropping"); message_free( msg ); return NULL; } @@ -52,14 +52,14 @@ osrfAppSession* osrf_stack_transport_handler( transport_message* msg, char* my_s if( !session ) return NULL; if(!msg->is_error) - osrfLogDebug("Session [%s] found or built", session->session_id ); + osrfLogDebug( OSRF_LOG_MARK, "Session [%s] found or built", session->session_id ); osrf_app_session_set_remote( session, msg->sender ); osrf_message* arr[OSRF_MAX_MSGS_PER_PACKET]; memset(arr, 0, OSRF_MAX_MSGS_PER_PACKET ); int num_msgs = osrf_message_deserialize(msg->body, arr, OSRF_MAX_MSGS_PER_PACKET); - osrfLogDebug( "We received %d messages from %s", num_msgs, msg->sender ); + osrfLogDebug( OSRF_LOG_MARK, "We received %d messages from %s", num_msgs, msg->sender ); int i; for( i = 0; i != num_msgs; i++ ) { @@ -68,17 +68,17 @@ osrfAppSession* osrf_stack_transport_handler( transport_message* msg, char* my_s someone who no longer exists) and we're not talking to the original remote id for this server, consider it a redirect and pass it up */ if(msg->is_error) { - osrfLogWarning( " !!! Received Jabber layer error message" ); + osrfLogWarning( OSRF_LOG_MARK, " !!! Received Jabber layer error message" ); if(strcmp(session->remote_id,session->orig_remote_id)) { - osrfLogWarning( "Treating jabber error as redirect for tt [%d] " + osrfLogWarning( OSRF_LOG_MARK, "Treating jabber error as redirect for tt [%d] " "and session [%s]", arr[i]->thread_trace, session->session_id ); arr[i]->m_type = STATUS; arr[i]->status_code = OSRF_STATUS_REDIRECTED; } else { - osrfLogWarning(" * Jabber Error is for top level remote id [%s], no one " + osrfLogWarning( OSRF_LOG_MARK, " * Jabber Error is for top level remote id [%s], no one " "to send my message too!!!", session->remote_id ); } } @@ -87,7 +87,7 @@ osrfAppSession* osrf_stack_transport_handler( transport_message* msg, char* my_s } message_free( msg ); - osrfLogDebug("after msg delete"); + osrfLogDebug( OSRF_LOG_MARK, "after msg delete"); return session; } @@ -104,7 +104,7 @@ int osrf_stack_message_handler( osrf_app_session* session, osrf_message* msg ) { ret_msg= _do_server( session, msg ); if(ret_msg) { - osrfLogDebug("passing message %d / session %s to app handler", + osrfLogDebug( OSRF_LOG_MARK, "passing message %d / session %s to app handler", msg->thread_trace, session->session_id ); osrf_stack_application_handler( session, ret_msg ); } else @@ -128,9 +128,9 @@ osrf_message* _do_client( osrf_app_session* session, osrf_message* msg ) { switch( msg->status_code ) { case OSRF_STATUS_OK: - osrfLogDebug("We connected successfully"); + osrfLogDebug( OSRF_LOG_MARK, "We connected successfully"); session->state = OSRF_SESSION_CONNECTED; - osrfLogDebug( "State: %x => %s => %d", session, session->session_id, session->state ); + osrfLogDebug( OSRF_LOG_MARK, "State: %x => %s => %d", session, session->session_id, session->state ); return NULL; case OSRF_STATUS_COMPLETE: @@ -165,7 +165,7 @@ osrf_message* _do_client( osrf_app_session* session, osrf_message* msg ) { new_msg = osrf_message_init( RESULT, msg->thread_trace, msg->protocol ); osrf_message_set_status_info( new_msg, msg->status_name, msg->status_text, msg->status_code ); - osrfLogWarning("The stack doesn't know what to do with " + osrfLogWarning( OSRF_LOG_MARK, "The stack doesn't know what to do with " "the provided message code: %d, name %s. Passing UP.", msg->status_code, msg->status_name ); new_msg->is_exception = 1; @@ -191,7 +191,7 @@ osrf_message* _do_server( osrf_app_session* session, osrf_message* msg ) { if(session == NULL || msg == NULL) return NULL; - osrfLogDebug("Server received message of type %d", msg->m_type ); + osrfLogDebug( OSRF_LOG_MARK, "Server received message of type %d", msg->m_type ); switch( msg->m_type ) { @@ -209,12 +209,12 @@ osrf_message* _do_server( osrf_app_session* session, osrf_message* msg ) { case REQUEST: - osrfLogDebug("server passing message %d to application handler " + osrfLogDebug( OSRF_LOG_MARK, "server passing message %d to application handler " "for session %s", msg->thread_trace, session->session_id ); return msg; default: - osrfLogWarning("Server cannot handle message of type %d", msg->m_type ); + osrfLogWarning( OSRF_LOG_MARK, "Server cannot handle message of type %d", msg->m_type ); return NULL; } diff --git a/src/libstack/osrf_system.c b/src/libstack/osrf_system.c index 794a1f5..1f9f06a 100644 --- a/src/libstack/osrf_system.c +++ b/src/libstack/osrf_system.c @@ -36,18 +36,18 @@ int _osrfSystemInitCache() { char* servers[cacheServers->size]; for( i = 0; i != cacheServers->size; i++ ) { servers[i] = jsonObjectGetString( jsonObjectGetIndex(cacheServers, i) ); - osrfLogInfo("Adding cache server %s", servers[i]); + osrfLogInfo( OSRF_LOG_MARK, "Adding cache server %s", servers[i]); } osrfCacheInit( servers, cacheServers->size, atoi(maxCache) ); } else { char* servers[] = { jsonObjectGetString(cacheServers) }; - osrfLogInfo("Adding cache server %s", servers[0]); + osrfLogInfo( OSRF_LOG_MARK, "Adding cache server %s", servers[0]); osrfCacheInit( servers, 1, atoi(maxCache) ); } } else { - osrfLogError( "Missing config value for /cache/global/servers/server _or_ " + osrfLogError( OSRF_LOG_MARK, "Missing config value for /cache/global/servers/server _or_ " "/cache/global/max_cache_time"); } @@ -60,7 +60,7 @@ int osrfSystemBootstrap( char* hostname, char* configfile, char* contextNode ) { /* first we grab the settings */ if(!osrfSystemBootstrapClientResc(configfile, contextNode, "settings_grabber" )) { - osrfLogError("Unable to bootstrap"); + osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap"); return -1; } @@ -95,17 +95,17 @@ int osrfSystemBootstrap( char* hostname, char* configfile, char* contextNode ) { char* libfile = osrf_settings_host_value("/apps/%s/implementation", appname); if(! (appname && libfile) ) { - osrfLogWarning("Missing appname / libfile in settings config"); + osrfLogWarning( OSRF_LOG_MARK, "Missing appname / libfile in settings config"); continue; } - osrfLogInfo("Launching application %s with implementation %s", appname, libfile); + osrfLogInfo( OSRF_LOG_MARK, "Launching application %s with implementation %s", appname, libfile); int pid; if( (pid = fork()) ) { // storage pid in local table for re-launching dead children... - osrfLogInfo("Launched application child %d", pid); + osrfLogInfo( OSRF_LOG_MARK, "Launched application child %d", pid); } else { @@ -113,7 +113,7 @@ int osrfSystemBootstrap( char* hostname, char* configfile, char* contextNode ) { if( osrfAppRegisterApplication( appname, libfile ) == 0 ) osrf_prefork_run(appname); - osrfLogDebug("Server exiting for app %s and library %s", appname, libfile ); + osrfLogDebug( OSRF_LOG_MARK, "Server exiting for app %s and library %s", appname, libfile ); exit(0); } } // language == c @@ -135,7 +135,7 @@ int osrfSystemBootstrap( char* hostname, char* configfile, char* contextNode ) { int osrf_system_bootstrap_client_resc( char* config_file, char* contextnode, char* resource ) { if( !( config_file && contextnode ) && ! osrfConfigHasDefaultConfig() ) { - osrfLogError("No Config File Specified\n" ); + osrfLogError( OSRF_LOG_MARK, "No Config File Specified\n" ); return -1; } @@ -178,7 +178,7 @@ int osrf_system_bootstrap_client_resc( char* config_file, char* contextnode, cha osrfLogSetFile( log_file ); } - osrfLogInfo("Bootstrapping system with domain %s, port %d, and unixpath %s", domain, iport, unixpath ); + osrfLogInfo( OSRF_LOG_MARK, "Bootstrapping system with domain %s, port %d, and unixpath %s", domain, iport, unixpath ); transport_client* client = client_init( domain, iport, unixpath, 0 ); @@ -237,7 +237,7 @@ void __osrfSystemSignalHandler( int sig ) { int status; while( (pid = waitpid(-1, &status, WNOHANG)) > 0) { - osrfLogWarning("We lost child %d", pid); + osrfLogWarning( OSRF_LOG_MARK, "We lost child %d", pid); } /** relaunch the server **/ diff --git a/src/libstack/osrf_transgroup.c b/src/libstack/osrf_transgroup.c index 83763ab..1d3d3f4 100644 --- a/src/libstack/osrf_transgroup.c +++ b/src/libstack/osrf_transgroup.c @@ -33,7 +33,7 @@ osrfTransportGroup* osrfNewTransportGroup( osrfTransportGroupNode* nodes[], int for( i = 0; i != count; i++ ) { if(!(nodes[i] && nodes[i]->domain) ) return NULL; osrfHashSet( grp->nodes, nodes[i], nodes[i]->domain ); - osrfLogDebug("Adding domain %s to TransportGroup", nodes[i]->domain); + osrfLogDebug( OSRF_LOG_MARK, "Adding domain %s to TransportGroup", nodes[i]->domain); } return grp; @@ -49,17 +49,17 @@ int osrfTransportGroupConnectAll( osrfTransportGroup* grp ) { osrfHashIteratorReset(grp->itr); while( (node = osrfHashIteratorNext(grp->itr)) ) { - osrfLogInfo("TransportGroup attempting to connect to domain %s", + osrfLogInfo( OSRF_LOG_MARK, "TransportGroup attempting to connect to domain %s", node->connection->session->server); if(client_connect( node->connection, node->username, node->password, node->resource, 10, AUTH_DIGEST )) { node->active = 1; active++; - osrfLogInfo("TransportGroup successfully connected to domain %s", + osrfLogInfo( OSRF_LOG_MARK, "TransportGroup successfully connected to domain %s", node->connection->session->server); } else { - osrfLogWarning("TransportGroup unable to connect to domain %s", + osrfLogWarning( OSRF_LOG_MARK, "TransportGroup unable to connect to domain %s", node->connection->session->server); } } @@ -75,7 +75,7 @@ void osrfTransportGroupDisconnectAll( osrfTransportGroup* grp ) { osrfHashIteratorReset(grp->itr); while( (node = osrfHashIteratorNext(grp->itr)) ) { - osrfLogInfo("TransportGroup disconnecting from domain %s", + osrfLogInfo( OSRF_LOG_MARK, "TransportGroup disconnecting from domain %s", node->connection->session->server); client_disconnect(node->connection); node->active = 0; @@ -98,7 +98,7 @@ int osrfTransportGroupSendMatch( osrfTransportGroup* grp, transport_message* msg return 0; } - osrfLogWarning("Error sending message to domain %s", domain ); + osrfLogWarning( OSRF_LOG_MARK, "Error sending message to domain %s", domain ); return -1; } @@ -141,7 +141,7 @@ int osrfTransportGroupSend( osrfTransportGroup* grp, transport_message* msg ) { } else { if(!strcmp(firstdomain, node->domain)) { /* we've made a full loop */ - osrfLogWarning("We've tried to send to all domains.. giving up"); + osrfLogWarning( OSRF_LOG_MARK, "We've tried to send to all domains.. giving up"); return -1; } } diff --git a/src/libtransport/basic_client.c b/src/libtransport/basic_client.c index 5f14e1f..d2178eb 100644 --- a/src/libtransport/basic_client.c +++ b/src/libtransport/basic_client.c @@ -11,7 +11,7 @@ void sig_int( int sig ) { int main( int argc, char** argv ) { if( argc < 5 ) { - osrfLogError( "Usage: %s \n", argv[0] ); + osrfLogError( OSRF_LOG_MARK, "Usage: %s \n", argv[0] ); return 99; } @@ -20,9 +20,9 @@ int main( int argc, char** argv ) { // try to connect, allow 15 second connect timeout if( client_connect( client, argv[1], "jkjkasdf", argv[3], 15, AUTH_DIGEST ) ) - osrfLogInfo("Connected...\n"); + osrfLogInfo(OSRF_LOG_MARK, "Connected...\n"); else { - osrfLogError( "NOT Connected...\n" ); + osrfLogError( OSRF_LOG_MARK, "NOT Connected...\n" ); return -1; } diff --git a/src/libtransport/component.c b/src/libtransport/component.c index ed58b4b..1f909d2 100644 --- a/src/libtransport/component.c +++ b/src/libtransport/component.c @@ -14,7 +14,7 @@ int main( int argc, char** argv ) { if( argc < 5 ) { - osrfLogError( "Usage: %s ", argv[0] ); + osrfLogError(OSRF_LOG_MARK, "Usage: %s ", argv[0] ); return -1; } @@ -23,9 +23,9 @@ int main( int argc, char** argv ) { // try to connect, allow 15 second connect timeout if( client_connect( client, argv[3], argv[4], "", 15, 1 ) ) - osrfLogInfo("Connected...\n"); + osrfLogInfo(OSRF_LOG_MARK, "Connected...\n"); else { - osrfLogError( "NOT Connected...\n" ); + osrfLogError(OSRF_LOG_MARK, "NOT Connected...\n" ); return -1; } diff --git a/src/libtransport/transport_client.c b/src/libtransport/transport_client.c index b660228..065a725 100644 --- a/src/libtransport/transport_client.c +++ b/src/libtransport/transport_client.c @@ -62,7 +62,7 @@ transport_client* client_init( char* server, int port, char* unix_path, int comp if(client->session == NULL) { - osrfLogError( "client_init(): Out of Memory"); + osrfLogError(OSRF_LOG_MARK, "client_init(): Out of Memory"); return NULL; } client->session->message_callback = client_message_handler; @@ -119,7 +119,7 @@ transport_message* client_recv( transport_client* client, int timeout ) { // if( ! session_wait( client->session, -1 ) ) { int x; if( (x = session_wait( client->session, -1 )) ) { - osrfLogWarning("session_wait returned failure code %d\n", x); + osrfLogWarning(OSRF_LOG_MARK, "session_wait returned failure code %d\n", x); return NULL; } } diff --git a/src/libtransport/transport_message.c b/src/libtransport/transport_message.c index b96fcd0..3995899 100644 --- a/src/libtransport/transport_message.c +++ b/src/libtransport/transport_message.c @@ -26,7 +26,7 @@ transport_message* message_init( char* body, msg->subject == NULL || msg->recipient == NULL || msg->sender == NULL ) { - osrfLogError( "message_init(): Out of Memory" ); + osrfLogError(OSRF_LOG_MARK, "message_init(): Out of Memory" ); return NULL; } @@ -130,7 +130,7 @@ transport_message* new_message_from_xml( const char* msg_xml ) { encoded_body = strdup( (char*) xmlbuf ); if( encoded_body == NULL ) - osrfLogError("message_to_xml(): Out of Memory"); + osrfLogError(OSRF_LOG_MARK, "message_to_xml(): Out of Memory"); xmlFree(xmlbuf); xmlFreeDoc(msg_doc); @@ -194,7 +194,7 @@ void message_set_router_info( transport_message* msg, char* router_from, if( msg->router_from == NULL || msg->router_to == NULL || msg->router_class == NULL || msg->router_command == NULL ) - osrfLogError( "message_set_router_info(): Out of Memory" ); + osrfLogError(OSRF_LOG_MARK, "message_set_router_info(): Out of Memory" ); return; } @@ -250,7 +250,7 @@ char* message_to_xml( const transport_message* msg ) { xmlKeepBlanksDefault(0); if( ! msg ) { - osrfLogWarning( "Passing NULL message to message_to_xml()"); + osrfLogWarning(OSRF_LOG_MARK, "Passing NULL message to message_to_xml()"); return 0; } @@ -313,7 +313,7 @@ char* message_to_xml( const transport_message* msg ) { encoded_body = strdup( (char*) xmlbuf ); if( encoded_body == NULL ) { - osrfLogError("message_to_xml(): Out of Memory"); + osrfLogError(OSRF_LOG_MARK, "message_to_xml(): Out of Memory"); return NULL; } diff --git a/src/libtransport/transport_session.c b/src/libtransport/transport_session.c index 09f2381..82b5415 100644 --- a/src/libtransport/transport_session.c +++ b/src/libtransport/transport_session.c @@ -41,7 +41,7 @@ transport_session* init_transport( char* server, session->router_class_buffer == NULL || session->router_command_buffer == NULL || session->session_id == NULL ) { - osrfLogError( "init_transport(): buffer_init returned NULL" ); + osrfLogError(OSRF_LOG_MARK, "init_transport(): buffer_init returned NULL" ); return 0; } @@ -128,7 +128,7 @@ int session_send_msg( if( ! session ) { return -1; } if( ! session->state_machine->connected ) { - osrfLogWarning("State machine is not connected in send_msg()"); + osrfLogWarning(OSRF_LOG_MARK, "State machine is not connected in send_msg()"); return -1; } @@ -148,7 +148,7 @@ int session_connect( transport_session* session, int size2 = 0; if( ! session ) { - osrfLogWarning( "session is null in connect" ); + osrfLogWarning(OSRF_LOG_MARK, "session is null in connect" ); return 0; } @@ -187,7 +187,7 @@ int session_connect( transport_session* session, // if( ! tcp_send( session->sock_obj, stanza1 ) ) { if( socket_send( session->sock_id, stanza1 ) ) { - osrfLogWarning("error sending"); + osrfLogWarning(OSRF_LOG_MARK, "error sending"); return 0; } @@ -211,7 +211,7 @@ int session_connect( transport_session* session, //if( ! tcp_send( session->sock_obj, stanza2 ) ) { if( socket_send( session->sock_id, stanza2 ) ) { - osrfLogWarning("error sending"); + osrfLogWarning(OSRF_LOG_MARK, "error sending"); return 0; } } @@ -232,7 +232,7 @@ int session_connect( transport_session* session, session->state_machine->connecting = CONNECTING_1; //if( ! tcp_send( session->sock_obj, stanza1 ) ) { if( socket_send( session->sock_id, stanza1 ) ) { - osrfLogWarning("error sending"); + osrfLogWarning(OSRF_LOG_MARK, "error sending"); return 0; } @@ -257,7 +257,7 @@ int session_connect( transport_session* session, if( session->state_machine->connecting == CONNECTING_2 ) { //if( ! tcp_send( session->sock_obj, stanza2 ) ) { if( socket_send( session->sock_id, stanza2 ) ) { - osrfLogWarning("error sending"); + osrfLogWarning(OSRF_LOG_MARK, "error sending"); return 0; } } @@ -285,7 +285,7 @@ int session_connect( transport_session* session, if( session->state_machine->connecting == CONNECTING_2 ) { //if( ! tcp_send( session->sock_obj, stanza2 ) ) { if( socket_send( session->sock_id, stanza2 ) ) { - osrfLogWarning("error sending"); + osrfLogWarning(OSRF_LOG_MARK, "error sending"); return 0; } } @@ -374,7 +374,7 @@ void startElementHandler( if( strcmp( name, "stream:error" ) == 0 ) { ses->state_machine->in_error = 1; - osrfLogWarning( "Received message from Jabber server" ); + osrfLogWarning( OSRF_LOG_MARK, "Received message from Jabber server" ); return; } @@ -398,7 +398,7 @@ void startElementHandler( ses->state_machine->in_message_error = 1; buffer_add( ses->message_error_type, get_xml_attr( atts, "type" ) ); ses->message_error_code = atoi( get_xml_attr( atts, "code" ) ); - osrfLogInfo( "Received message with type %s and code %s", + osrfLogInfo( OSRF_LOG_MARK, "Received message with type %s and code %s", get_xml_attr( atts, "type"), get_xml_attr( atts, "code") ); return; } @@ -414,7 +414,7 @@ void startElementHandler( } if( strcmp( get_xml_attr(atts, "type"), "error") == 0 ) { - osrfLogWarning( "Error connecting to jabber" ); + osrfLogWarning( OSRF_LOG_MARK, "Error connecting to jabber" ); return; } } @@ -496,8 +496,8 @@ void endElementHandler( void *session, const xmlChar *name) { if( strcmp( name, "iq" ) == 0 ) { ses->state_machine->in_iq = 0; if( ses->message_error_code > 0 ) { - osrfLogWarning( "Error in IQ packet: code %d", ses->message_error_code ); - osrfLogWarning( "Error 401 means not authorized" ); + osrfLogWarning( OSRF_LOG_MARK, "Error in IQ packet: code %d", ses->message_error_code ); + osrfLogWarning( OSRF_LOG_MARK, "Error 401 means not authorized" ); } reset_session_buffers( session ); return; @@ -585,7 +585,7 @@ void characterHandler( if( ses->state_machine->in_error ) { /* for now... */ - osrfLogWarning( "ERROR Xml fragment: %s\n", ch ); + osrfLogWarning( OSRF_LOG_MARK, "ERROR Xml fragment: %s\n", ch ); } } diff --git a/src/router/osrf_router.c b/src/router/osrf_router.c index 047bad8..ce97a07 100644 --- a/src/router/osrf_router.c +++ b/src/router/osrf_router.c @@ -57,14 +57,14 @@ void osrfRouterRun( osrfRouter* router ) { int numhandled = 0; if( (selectret = select(maxfd + 1, &set, NULL, NULL, NULL)) < 0 ) { - osrfLogWarning("Top level select call failed with errno %d", errno); + osrfLogWarning( OSRF_LOG_MARK, "Top level select call failed with errno %d", errno); continue; } /* see if there is a top level router message */ if( FD_ISSET(routerfd, &set) ) { - osrfLogDebug("Top router socket is active: %d", routerfd ); + osrfLogDebug( OSRF_LOG_MARK, "Top router socket is active: %d", routerfd ); numhandled++; osrfRouterHandleIncoming( router ); } @@ -82,11 +82,11 @@ void osrfRouterRun( osrfRouter* router ) { if( classname && (class = osrfRouterFindClass( router, classname )) ) { - osrfLogDebug("Checking %s for activity...", classname ); + osrfLogDebug( OSRF_LOG_MARK, "Checking %s for activity...", classname ); int sockfd = class->ROUTER_SOCKFD; if(FD_ISSET( sockfd, &set )) { - osrfLogDebug("Socket is active: %d", sockfd ); + osrfLogDebug( OSRF_LOG_MARK, "Socket is active: %d", sockfd ); numhandled++; osrfRouterClassHandleIncoming( router, classname, class ); } @@ -117,7 +117,7 @@ void osrfRouterHandleIncoming( osrfRouter* router ) { if(osrfStringArrayContains( router->trustedServers, domain)) osrfRouterHandleMessage( router, msg ); else - osrfLogWarning("Received message from un-trusted server domain %s", msg->sender); + osrfLogWarning( OSRF_LOG_MARK, "Received message from un-trusted server domain %s", msg->sender); } message_free(msg); @@ -128,7 +128,7 @@ int osrfRouterClassHandleIncoming( osrfRouter* router, char* classname, osrfRout if(!(router && class)) return -1; transport_message* msg; - osrfLogDebug("osrfRouterClassHandleIncoming()"); + osrfLogDebug( OSRF_LOG_MARK, "osrfRouterClassHandleIncoming()"); if( (msg = client_recv( class->connection, 0 )) ) { @@ -155,7 +155,7 @@ int osrfRouterClassHandleIncoming( osrfRouter* router, char* classname, osrfRout osrfRouterClassHandleMessage( router, class, msg ); } else { - osrfLogWarning("Received client message from untrusted client domain %s", domain ); + osrfLogWarning( OSRF_LOG_MARK, "Received client message from untrusted client domain %s", domain ); } } @@ -180,7 +180,7 @@ int osrfRouterHandleMessage( osrfRouter* router, transport_message* msg ) { if(!strcmp(msg->router_command, ROUTER_REGISTER)) { class = osrfRouterFindClass( router, msg->router_class ); - osrfLogInfo("Registering class %s", msg->router_class ); + osrfLogInfo( OSRF_LOG_MARK, "Registering class %s", msg->router_class ); if(!class) class = osrfRouterAddClass( router, msg->router_class ); @@ -196,7 +196,7 @@ int osrfRouterHandleMessage( osrfRouter* router, transport_message* msg ) { } else if( !strcmp( msg->router_command, ROUTER_UNREGISTER ) ) { if( msg->router_class && strcmp( msg->router_class, "") ) { - osrfLogInfo("Unregistering router class %s", msg->router_class ); + osrfLogInfo( OSRF_LOG_MARK, "Unregistering router class %s", msg->router_class ); osrfRouterClassRemoveNode( router, msg->router_class, msg->sender ); } } @@ -231,7 +231,7 @@ osrfRouterClass* osrfRouterAddClass( osrfRouter* router, char* classname ) { int osrfRouterClassAddNode( osrfRouterClass* rclass, char* remoteId ) { if(!(rclass && rclass->nodes && remoteId)) return -1; - osrfLogInfo("Adding router node for remote id %s", remoteId ); + osrfLogInfo( OSRF_LOG_MARK, "Adding router node for remote id %s", remoteId ); osrfRouterNode* node = safe_malloc(sizeof(osrfRouterNode)); node->count = 0; @@ -249,16 +249,16 @@ int osrfRouterClassAddNode( osrfRouterClass* rclass, char* remoteId ) { transport_message* osrfRouterClassHandleBounce( osrfRouter* router, char* classname, osrfRouterClass* rclass, transport_message* msg ) { - osrfLogDebug("osrfRouterClassHandleBounce()"); + osrfLogDebug( OSRF_LOG_MARK, "osrfRouterClassHandleBounce()"); - osrfLogInfo("Received network layer error message from %s", msg->sender ); + osrfLogInfo( OSRF_LOG_MARK, "Received network layer error message from %s", msg->sender ); osrfRouterNode* node = osrfRouterClassFindNode( rclass, msg->sender ); transport_message* lastSent = NULL; if( node && osrfHashGetCount(rclass->nodes) == 1 ) { /* the last node is dead */ if( node->lastMessage ) { - osrfLogWarning("We lost the last node in the class, responding with error and removing..."); + osrfLogWarning( OSRF_LOG_MARK, "We lost the last node in the class, responding with error and removing..."); transport_message* error = message_init( node->lastMessage->body, node->lastMessage->subject, @@ -275,7 +275,7 @@ transport_message* osrfRouterClassHandleBounce( } else { if( node->lastMessage ) { - osrfLogDebug("Cloning lastMessage so next node can send it"); + osrfLogDebug( OSRF_LOG_MARK, "Cloning lastMessage so next node can send it"); lastSent = message_init( node->lastMessage->body, node->lastMessage->subject, node->lastMessage->thread, "", node->lastMessage->router_from ); message_set_router_info( lastSent, node->lastMessage->router_from, NULL, NULL, NULL, 0 ); @@ -298,7 +298,7 @@ int osrfRouterClassHandleMessage( osrfRouter* router, osrfRouterClass* rclass, transport_message* msg ) { if(!(router && rclass && msg)) return -1; - osrfLogDebug("osrfRouterClassHandleMessage()"); + osrfLogDebug( OSRF_LOG_MARK, "osrfRouterClassHandleMessage()"); osrfRouterNode* node = osrfHashIteratorNext( rclass->itr ); if(!node) { @@ -312,7 +312,7 @@ int osrfRouterClassHandleMessage( msg->subject, msg->thread, node->remoteId, msg->sender ); message_set_router_info( new_msg, msg->sender, NULL, NULL, NULL, 0 ); - osrfLogInfo( "Routing message:\nfrom: [%s]\nto: [%s]", + osrfLogInfo( OSRF_LOG_MARK, "Routing message:\nfrom: [%s]\nto: [%s]", new_msg->router_from, new_msg->recipient ); message_free( node->lastMessage ); @@ -323,7 +323,7 @@ int osrfRouterClassHandleMessage( else { message_prepare_xml(new_msg); - osrfLogWarning("Error sending message from %s to %s\n%s", + osrfLogWarning( OSRF_LOG_MARK, "Error sending message from %s to %s\n%s", new_msg->sender, new_msg->recipient, new_msg->msg_xml ); } @@ -335,7 +335,7 @@ int osrfRouterClassHandleMessage( int osrfRouterRemoveClass( osrfRouter* router, char* classname ) { if(!(router && router->classes && classname)) return -1; - osrfLogInfo("Removing router class %s", classname ); + osrfLogInfo( OSRF_LOG_MARK, "Removing router class %s", classname ); osrfHashRemove( router->classes, classname ); return 0; } @@ -346,7 +346,7 @@ int osrfRouterClassRemoveNode( if(!(router && router->classes && classname && remoteId)) return 0; - osrfLogInfo("Removing router node %s", remoteId ); + osrfLogInfo( OSRF_LOG_MARK, "Removing router node %s", remoteId ); osrfRouterClass* class = osrfRouterFindClass( router, classname ); @@ -491,7 +491,7 @@ int osrfRouterRespondConnect( osrfRouter* router, transport_message* msg, osrfMe osrfMessage* success = osrf_message_init( STATUS, omsg->thread_trace, omsg->protocol ); - osrfLogDebug("router recevied a CONNECT message from %s", msg->sender ); + osrfLogDebug( OSRF_LOG_MARK, "router recevied a CONNECT message from %s", msg->sender ); osrf_message_set_status_info( success, "osrfConnectStatus", "Connection Successful", OSRF_STATUS_OK ); @@ -516,7 +516,7 @@ int osrfRouterProcessAppRequest( osrfRouter* router, transport_message* msg, osr if(!(router && msg && omsg && omsg->method_name)) return -1; - osrfLogInfo("Router received app request: %s", omsg->method_name ); + osrfLogInfo( OSRF_LOG_MARK, "Router received app request: %s", omsg->method_name ); jsonObject* jresponse = NULL; if(!strcmp( omsg->method_name, ROUTER_REQUEST_CLASS_LIST )) { @@ -579,7 +579,7 @@ int osrfRouterHandleAppResponse( osrfRouter* router, osrf_message_set_result_content( oresponse, json); char* data = osrf_message_serialize(oresponse); - osrfLogDebug( "Responding to client app request with data: \n%s\n", data ); + osrfLogDebug( OSRF_LOG_MARK, "Responding to client app request with data: \n%s\n", data ); transport_message* tresponse = message_init( data, "", msg->thread, msg->sender, msg->recipient ); diff --git a/src/router/osrf_router_main.c b/src/router/osrf_router_main.c index 5875f73..aaa3843 100644 --- a/src/router/osrf_router_main.c +++ b/src/router/osrf_router_main.c @@ -7,7 +7,7 @@ osrfRouter* __osrfRouter = NULL; void routerSignalHandler( int signal ) { - osrfLogWarning("Received signal [%d], cleaning up...", signal ); + osrfLogWarning( OSRF_LOG_MARK, "Received signal [%d], cleaning up...", signal ); osrfConfigCleanup(); osrfRouterFree(__osrfRouter); } @@ -18,7 +18,7 @@ static int __setupRouter( char* config, char* context ); int main( int argc, char* argv[] ) { if( argc < 3 ) { - osrfLogError( "Usage: %s ", argv[0] ); + osrfLogError( OSRF_LOG_MARK, "Usage: %s ", argv[0] ); exit(0); } @@ -74,7 +74,7 @@ int __setupRouter( char* config, char* context ) { free(level); free(log_file); - osrfLogInfo( "Router connecting as: server: %s port: %s " + osrfLogInfo( OSRF_LOG_MARK, "Router connecting as: server: %s port: %s " "user: %s resource: %s", server, port, username, resource ); int iport = 0; @@ -87,13 +87,13 @@ int __setupRouter( char* config, char* context ) { int i; for( i = 0; i != tservers->size; i++ ) - osrfLogInfo( "Router adding trusted server: %s", osrfStringArrayGetString( tservers, i ) ); + osrfLogInfo( OSRF_LOG_MARK, "Router adding trusted server: %s", osrfStringArrayGetString( tservers, i ) ); for( i = 0; i != tclients->size; i++ ) - osrfLogInfo( "Router adding trusted client: %s", osrfStringArrayGetString( tclients, i ) ); + osrfLogInfo( OSRF_LOG_MARK, "Router adding trusted client: %s", osrfStringArrayGetString( tclients, i ) ); if( tclients->size == 0 || tservers->size == 0 ) { - osrfLogError("We need trusted servers and trusted client to run the router..."); + osrfLogError( OSRF_LOG_MARK, "We need trusted servers and trusted client to run the router..."); return -1; } diff --git a/src/srfsh/srfsh.c b/src/srfsh/srfsh.c index b1c49a5..c6d124c 100644 --- a/src/srfsh/srfsh.c +++ b/src/srfsh/srfsh.c @@ -15,12 +15,10 @@ int main( int argc, char* argv[] ) { memset(fbuf, 0, l); sprintf(fbuf,"%s/.srfsh.xml",home); - //osrfLogInit( OSRF_LOG_TYPE_SYSLOG, "srfsh", - if(!access(fbuf, R_OK)) { if( ! osrf_system_bootstrap_client(fbuf, "srfsh") ) { fprintf(stderr,"Unable to bootstrap client for requests\n"); - osrfLogError( "Unable to bootstrap client for requests"); + osrfLogError( OSRF_LOG_MARK, "Unable to bootstrap client for requests"); return -1; } @@ -33,12 +31,12 @@ int main( int argc, char* argv[] ) { /* for now.. the first arg is used as a script file for processing */ int f; if( (f = open(argv[1], O_RDONLY)) == -1 ) { - osrfLogError("Unable to open file %s for reading, exiting...", argv[1]); + osrfLogError( OSRF_LOG_MARK, "Unable to open file %s for reading, exiting...", argv[1]); return -1; } if(dup2(f, STDIN_FILENO) == -1) { - osrfLogError("Unable to duplicate STDIN, exiting..."); + osrfLogError( OSRF_LOG_MARK, "Unable to duplicate STDIN, exiting..."); return -1; } @@ -523,7 +521,7 @@ int send_request( char* server, osrf_app_session* session = osrf_app_client_session_init(server); if(!osrf_app_session_connect(session)) { - osrfLogWarning( "Unable to connect to remote service %s\n", server ); + osrfLogWarning( OSRF_LOG_MARK, "Unable to connect to remote service %s\n", server ); return 1; } diff --git a/src/utils/log.c b/src/utils/log.c index c07535f..755b8d0 100644 --- a/src/utils/log.c +++ b/src/utils/log.c @@ -59,34 +59,27 @@ void osrfLogSetLevel( int loglevel ) { __osrfLogLevel = loglevel; } -void osrfLogError( const char* msg, ... ) { OSRF_LOG_GO(msg, OSRF_LOG_ERROR); } -void osrfLogWarning( const char* msg, ... ) { OSRF_LOG_GO(msg, OSRF_LOG_WARNING); } -void osrfLogInfo( const char* msg, ... ) { OSRF_LOG_GO(msg, OSRF_LOG_INFO); } -void osrfLogDebug( const char* msg, ... ) { OSRF_LOG_GO(msg, OSRF_LOG_DEBUG); } -void osrfLogInternal( const char* msg, ... ) { OSRF_LOG_GO(msg, OSRF_LOG_INTERNAL); } -void osrfLogActivity( const char* msg, ... ) { - OSRF_LOG_GO(msg, OSRF_LOG_ACTIVITY); - /* activity log entries are also logged as info intries */ - osrfLogDetail( OSRF_LOG_INFO, NULL, -1, NULL, VA_BUF ); +void osrfLogError( const char* file, int line, const char* msg, ... ) + { OSRF_LOG_GO(file, line, msg, OSRF_LOG_ERROR); } +void osrfLogWarning( const char* file, int line, const char* msg, ... ) + { OSRF_LOG_GO(file, line, msg, OSRF_LOG_WARNING); } +void osrfLogInfo( const char* file, int line, const char* msg, ... ) + { OSRF_LOG_GO(file, line, msg, OSRF_LOG_INFO); } +void osrfLogDebug( const char* file, int line, const char* msg, ... ) + { OSRF_LOG_GO(file, line, msg, OSRF_LOG_DEBUG); } +void osrfLogInternal( const char* file, int line, const char* msg, ... ) + { OSRF_LOG_GO(file, line, msg, OSRF_LOG_INTERNAL); } +void osrfLogActivity( const char* file, int line, const char* msg, ... ) { + OSRF_LOG_GO(file, line, msg, OSRF_LOG_ACTIVITY); + _osrfLogDetail( OSRF_LOG_INFO, file, line, VA_BUF ); /* also log at info level */ } -void osrfLogDetail( int level, char* filename, int line, char* func, char* msg, ... ) { - if(!msg) return; - VA_LIST_TO_STRING(msg); - _osrfLogDetail( level, filename, line, func, VA_BUF ); -} - -void _osrfLogDetail( int level, char* filename, int line, char* func, char* msg ) { +void _osrfLogDetail( int level, const char* filename, int line, char* msg ) { if( level == OSRF_LOG_ACTIVITY && ! __osrfLogActivityEnabled ) return; if( level > __osrfLogLevel ) return; if(!msg) return; if(!filename) filename = ""; - if(!func) func = ""; - - char lb[12]; - bzero(lb,12); - if(line >= 0) snprintf(lb,12,"%d", line); char* l = "INFO"; /* level name */ int lvl = LOG_INFO; /* syslog level */ @@ -126,10 +119,10 @@ void _osrfLogDetail( int level, char* filename, int line, char* func, char* msg } if(__osrfLogType == OSRF_LOG_TYPE_SYSLOG ) - syslog( fac | lvl, "[%s:%d:%s:%s:%s] %s", l, getpid(), filename, lb, func, msg ); + syslog( fac | lvl, "[%s:%d:%s:%d] %s", l, getpid(), filename, line, msg ); else if( __osrfLogType == OSRF_LOG_TYPE_FILE ) - _osrfLogToFile("[%s:%d:%s:%s:%s] %s", l, getpid(), filename, lb, func, msg ); + _osrfLogToFile("[%s:%d:%s:%d] %s", l, getpid(), filename, line, msg ); } @@ -149,7 +142,7 @@ void _osrfLogToFile( char* msg, ... ) { bzero(datebuf,36); time_t t = time(NULL); struct tm* tms = localtime(&t); - strftime(datebuf, 36, "%Y-%m-%d %h:%m:%s", tms); + strftime(datebuf, 36, "%Y-%m-%d %H:%M:%S", tms); FILE* file = fopen(__osrfLogFile, "a"); if(!file) { @@ -159,7 +152,7 @@ void _osrfLogToFile( char* msg, ... ) { fprintf(file, "%s %s %s\n", __osrfLogAppname, datebuf, VA_BUF ); if( fclose(file) != 0 ) - osrfLogWarning("Error closing log file: %s", strerror(errno)); + osrfLogWarning(OSRF_LOG_MARK, "Error closing log file: %s", strerror(errno)); } diff --git a/src/utils/log.h b/src/utils/log.h index 68efc39..61f59f3 100644 --- a/src/utils/log.h +++ b/src/utils/log.h @@ -18,11 +18,13 @@ #define OSRF_LOG_TYPE_FILE 1 #define OSRF_LOG_TYPE_SYSLOG 2 +#define OSRF_LOG_MARK __FILE__, __LINE__ -#define OSRF_LOG_GO(m,l) \ + +#define OSRF_LOG_GO(f,li,m,l) \ if(!m) return; \ VA_LIST_TO_STRING(m); \ - _osrfLogDetail( l, NULL, -1, NULL, VA_BUF ); + _osrfLogDetail( l, f, li, VA_BUF ); @@ -43,26 +45,23 @@ void osrfLogSetAppname( const char* appname ); * than "level" will not be logged */ void osrfLogSetLevel( int loglevel ); /* Log an error message */ -void osrfLogError( const char* msg, ... ); +void osrfLogError( const char* file, int line, const char* msg, ... ); /* Log a warning message */ -void osrfLogWarning( const char* msg, ... ); +void osrfLogWarning( const char* file, int line, const char* msg, ... ); /* log an info message */ -void osrfLogInfo( const char* msg, ... ); +void osrfLogInfo( const char* file, int line, const char* msg, ... ); /* Log a debug message */ -void osrfLogDebug( const char* msg, ... ); +void osrfLogDebug( const char* file, int line, const char* msg, ... ); /* Log an internal debug message */ -void osrfLogInternal( const char* msg, ... ); +void osrfLogInternal( const char* file, int line, const char* msg, ... ); /* Log an activity message */ -void osrfLogActivity( const char* msg, ... ); +void osrfLogActivity( const char* file, int line, const char* msg, ... ); +/* sets the activity flag */ void osrfLogSetActivityEnabled( int enabled ); -/* Use this for logging detailed message containing the filename, line number - * and function name in addition to the usual level and message */ -void osrfLogDetail( int level, char* filename, int line, char* func, char* msg, ... ); - /** Actually does the logging */ -void _osrfLogDetail( int level, char* filename, int line, char* func, char* msg ); +void _osrfLogDetail( int level, const char* filename, int line, char* msg ); void _osrfLogToFile( char* msg, ... ); diff --git a/src/utils/socket_bundle.c b/src/utils/socket_bundle.c index 4849fa2..e11a4b1 100644 --- a/src/utils/socket_bundle.c +++ b/src/utils/socket_bundle.c @@ -38,32 +38,12 @@ int main(int argc, char* argv[]) { /* -------------------------------------------------------------------- */ -/* -int osrfLogDebug(char* msg, ...) { - va_list args; - va_start(args, msg); - vfprintf(stderr, msg, args); - va_end(args); - fprintf( stderr, "\n" ); - return -1; -} - -int osrfLogWarning(char* msg, ...) { - va_list args; - va_start(args, msg); - vfprintf(stderr, msg, args); - va_end(args); - fprintf( stderr, "\n" ); - return -1; -} -*/ - socket_node* _socket_add_node(socket_manager* mgr, int endpoint, int addr_type, int sock_fd, int parent_id ) { if(mgr == NULL) return NULL; - osrfLogInternal("Adding socket node with fd %d", sock_fd); + osrfLogInternal( OSRF_LOG_MARK, "Adding socket node with fd %d", sock_fd); socket_node* new_node = safe_malloc(sizeof(socket_node)); new_node->endpoint = endpoint; @@ -85,7 +65,7 @@ socket_node* _socket_add_node(socket_manager* mgr, int socket_open_tcp_server(socket_manager* mgr, int port, char* listen_ip) { if( mgr == NULL ) { - osrfLogWarning("socket_open_tcp_server(): NULL mgr"); + osrfLogWarning( OSRF_LOG_MARK, "socket_open_tcp_server(): NULL mgr"); return -1; } @@ -95,7 +75,7 @@ int socket_open_tcp_server(socket_manager* mgr, int port, char* listen_ip) { sock_fd = socket(AF_INET, SOCK_STREAM, 0); if(sock_fd < 0) { - osrfLogWarning("tcp_server_connect(): Unable to create socket"); + osrfLogWarning( OSRF_LOG_MARK, "tcp_server_connect(): Unable to create socket"); return -1; } @@ -110,12 +90,12 @@ int socket_open_tcp_server(socket_manager* mgr, int port, char* listen_ip) { server_addr.sin_port = htons(port); if(bind( sock_fd, (struct sockaddr*) &server_addr, sizeof(server_addr)) < 0) { - osrfLogWarning("tcp_server_connect(): cannot bind to port %d", port ); + osrfLogWarning( OSRF_LOG_MARK, "tcp_server_connect(): cannot bind to port %d", port ); return -1; } if(listen(sock_fd, 20) == -1) { - osrfLogWarning("tcp_server_connect(): listen() returned error"); + osrfLogWarning( OSRF_LOG_MARK, "tcp_server_connect(): listen() returned error"); return -1; } @@ -126,13 +106,13 @@ int socket_open_tcp_server(socket_manager* mgr, int port, char* listen_ip) { int socket_open_unix_server(socket_manager* mgr, char* path) { if(mgr == NULL || path == NULL) return -1; - osrfLogDebug("opening unix socket at %s", path); + osrfLogDebug( OSRF_LOG_MARK, "opening unix socket at %s", path); int sock_fd; struct sockaddr_un server_addr; sock_fd = socket(AF_UNIX, SOCK_STREAM, 0); if(sock_fd < 0){ - osrfLogWarning("socket_open_unix_server(): socket() failed"); + osrfLogWarning( OSRF_LOG_MARK, "socket_open_unix_server(): socket() failed"); return -1; } @@ -141,25 +121,25 @@ int socket_open_unix_server(socket_manager* mgr, char* path) { if( bind(sock_fd, (struct sockaddr*) &server_addr, sizeof(struct sockaddr_un)) < 0) { - osrfLogWarning( + osrfLogWarning( OSRF_LOG_MARK, "socket_open_unix_server(): cannot bind to unix port %s", path ); return -1; } if(listen(sock_fd, 20) == -1) { - osrfLogWarning("socket_open_unix_server(): listen() returned error"); + osrfLogWarning( OSRF_LOG_MARK, "socket_open_unix_server(): listen() returned error"); return -1; } - osrfLogDebug("unix socket successfully opened"); + osrfLogDebug( OSRF_LOG_MARK, "unix socket successfully opened"); int i = 1; /* causing problems with router for some reason ... */ - //osrfLogDebug("Setting SO_REUSEADDR"); + //osrfLogDebug( OSRF_LOG_MARK, "Setting SO_REUSEADDR"); //setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i)); - //osrfLogDebug("Setting TCP_NODELAY"); + //osrfLogDebug( OSRF_LOG_MARK, "Setting TCP_NODELAY"); setsockopt(sock_fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i)); _socket_add_node(mgr, SERVER_SOCKET, UNIX, sock_fd, 0); @@ -175,7 +155,7 @@ int socket_open_udp_server( struct sockaddr_in server_addr; if( (sockfd = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 ) { - osrfLogWarning("Unable to create UDP socket"); + osrfLogWarning( OSRF_LOG_MARK, "Unable to create UDP socket"); return -1; } @@ -185,7 +165,7 @@ int socket_open_udp_server( else server_addr.sin_addr.s_addr = htonl(INADDR_ANY); if( (bind (sockfd, (struct sockaddr *) &server_addr,sizeof(server_addr))) ) { - osrfLogWarning("Unable to bind to UDP port %d", port); + osrfLogWarning( OSRF_LOG_MARK, "Unable to bind to UDP port %d", port); return -1; } @@ -204,12 +184,12 @@ int socket_open_tcp_client(socket_manager* mgr, int port, char* dest_addr) { // Create the socket // ------------------------------------------------------------------ if( (sock_fd = socket( AF_INET, SOCK_STREAM, 0 )) < 0 ) { - osrfLogWarning( "tcp_connect(): Cannot create socket" ); + osrfLogWarning( OSRF_LOG_MARK, "tcp_connect(): Cannot create socket" ); return -1; } int i = 1; - //osrfLogDebug("Setting TCP_NODELAY"); + //osrfLogDebug( OSRF_LOG_MARK, "Setting TCP_NODELAY"); setsockopt(sock_fd, IPPROTO_TCP, TCP_NODELAY, &i, sizeof(i)); @@ -217,7 +197,7 @@ int socket_open_tcp_client(socket_manager* mgr, int port, char* dest_addr) { // Get the hostname // ------------------------------------------------------------------ if( (hptr = gethostbyname( dest_addr ) ) == NULL ) { - osrfLogWarning( "tcp_connect(): Unknown Host => %s", dest_addr ); + osrfLogWarning( OSRF_LOG_MARK, "tcp_connect(): Unknown Host => %s", dest_addr ); return -1; } @@ -242,7 +222,7 @@ int socket_open_tcp_client(socket_manager* mgr, int port, char* dest_addr) { // Bind to a local port // ------------------------------------------------------------------ if( bind( sock_fd, (struct sockaddr *) &localAddr, sizeof( localAddr ) ) < 0 ) { - osrfLogWarning( "tcp_connect(): Cannot bind to local port" ); + osrfLogWarning( OSRF_LOG_MARK, "tcp_connect(): Cannot bind to local port" ); return -1; } @@ -250,7 +230,7 @@ int socket_open_tcp_client(socket_manager* mgr, int port, char* dest_addr) { // Connect to server // ------------------------------------------------------------------ if( connect( sock_fd, (struct sockaddr*) &remoteAddr, sizeof( struct sockaddr_in ) ) < 0 ) { - osrfLogWarning( "tcp_connect(): Cannot connect to server %s", dest_addr ); + osrfLogWarning( OSRF_LOG_MARK, "tcp_connect(): Cannot connect to server %s", dest_addr ); return -1; } @@ -268,7 +248,7 @@ int socket_open_udp_client( struct hostent* host; if( (host = gethostbyname(dest_addr)) == NULL) { - osrfLogWarning("Unable to resolve host: %s", dest_addr); + osrfLogWarning( OSRF_LOG_MARK, "Unable to resolve host: %s", dest_addr); return -1; } @@ -278,7 +258,7 @@ int socket_open_udp_client( server_addr.sin_port = htons(port); if( (sockfd = socket(AF_INET,SOCK_DGRAM,0)) < 0 ) { - osrfLogWarning("Unable to create UDP socket"); + osrfLogWarning( OSRF_LOG_MARK, "Unable to create UDP socket"); return -1; } @@ -287,7 +267,7 @@ int socket_open_udp_client( client_addr.sin_port = htons(0); if( (bind(sockfd, (struct sockaddr *) &client_addr, sizeof(client_addr))) < 0 ) { - osrfLogWarning("Unable to bind UDP socket"); + osrfLogWarning( OSRF_LOG_MARK, "Unable to bind UDP socket"); return -1; } @@ -303,7 +283,7 @@ int socket_open_unix_client(socket_manager* mgr, char* sock_path) { struct sockaddr_un usock; if( (sock_fd = socket( AF_UNIX, SOCK_STREAM, 0 )) < 0 ) { - osrfLogWarning( "Cannot create socket" ); + osrfLogWarning( OSRF_LOG_MARK, "Cannot create socket" ); return -1; } @@ -313,7 +293,7 @@ int socket_open_unix_client(socket_manager* mgr, char* sock_path) { len = sizeof( usock.sun_family ) + strlen( usock.sun_path ); if( connect( sock_fd, (struct sockaddr *) &usock, len ) < 0 ) { - osrfLogWarning( "Error connecting to unix socket" ); + osrfLogWarning( OSRF_LOG_MARK, "Error connecting to unix socket" ); return -1; } @@ -341,7 +321,7 @@ void socket_remove_node(socket_manager* mgr, int sock_fd) { if(mgr == NULL) return; - osrfLogDebug("removing socket %d", sock_fd); + osrfLogDebug( OSRF_LOG_MARK, "removing socket %d", sock_fd); socket_node* head = mgr->socket; socket_node* tail = head; @@ -373,23 +353,23 @@ void socket_remove_node(socket_manager* mgr, int sock_fd) { void _socket_print_list(socket_manager* mgr) { if(mgr == NULL) return; socket_node* node = mgr->socket; - osrfLogDebug("socket_node list: ["); + osrfLogDebug( OSRF_LOG_MARK, "socket_node list: ["); while(node) { - osrfLogDebug("sock_fd: %d | parent_id: %d", + osrfLogDebug( OSRF_LOG_MARK, "sock_fd: %d | parent_id: %d", node->sock_fd, node->parent_id); node = node->next; } - osrfLogDebug("]"); + osrfLogDebug( OSRF_LOG_MARK, "]"); } /* sends the given data to the given socket */ int socket_send(int sock_fd, const char* data) { - osrfLogInternal( "socket_bundle sending to %d data %s", + osrfLogInternal( OSRF_LOG_MARK, "socket_bundle sending to %d data %s", sock_fd, data); signal(SIGPIPE, SIG_IGN); /* in case a unix socket was closed */ if( send( sock_fd, data, strlen(data), 0 ) < 0 ) { - osrfLogWarning( "tcp_server_send(): Error sending data" ); + osrfLogWarning( OSRF_LOG_MARK, "tcp_server_send(): Error sending data" ); return -1; } @@ -400,10 +380,10 @@ int socket_send(int sock_fd, const char* data) { it from the socket set */ void socket_disconnect(socket_manager* mgr, int sock_fd) { - osrfLogDebug("Closing socket %d", sock_fd); + osrfLogDebug( OSRF_LOG_MARK, "Closing socket %d", sock_fd); if( close( sock_fd ) == -1 ) - osrfLogWarning( "socket_disconnect(): Error closing socket, removing anyway" ); + osrfLogWarning( OSRF_LOG_MARK, "socket_disconnect(): Error closing socket, removing anyway" ); if(mgr != NULL) socket_remove_node(mgr, sock_fd); @@ -439,21 +419,21 @@ int socket_wait(socket_manager* mgr, int timeout, int sock_fd) { // If timeout is -1, we block indefinitely if( (retval = select( sock_fd + 1, &read_set, NULL, NULL, NULL)) == -1 ) { - osrfLogWarning("Sys Error: %s", strerror(errno)); - osrfLogWarning("Call to select interrupted"); + osrfLogWarning( OSRF_LOG_MARK, "Sys Error: %s", strerror(errno)); + osrfLogWarning( OSRF_LOG_MARK, "Call to select interrupted"); return -1; } } else if( timeout > 0 ) { /* timeout of 0 means don't block */ if( (retval = select( sock_fd + 1, &read_set, NULL, NULL, &tv)) == -1 ) { - osrfLogWarning("Sys Error: %s", strerror(errno)); - osrfLogWarning( "Call to select interrupted" ); + osrfLogWarning( OSRF_LOG_MARK, "Sys Error: %s", strerror(errno)); + osrfLogWarning( OSRF_LOG_MARK, "Call to select interrupted" ); return -1; } } - osrfLogInternal("%d active sockets after select()", retval); + osrfLogInternal( OSRF_LOG_MARK, "%d active sockets after select()", retval); return _socket_route_data_id(mgr, sock_fd); } @@ -461,7 +441,7 @@ int socket_wait(socket_manager* mgr, int timeout, int sock_fd) { int socket_wait_all(socket_manager* mgr, int timeout) { if(mgr == NULL) { - osrfLogWarning( "tcp_wait(): null mgr" ); + osrfLogWarning( OSRF_LOG_MARK, "tcp_wait(): null mgr" ); return -1; } @@ -472,7 +452,7 @@ int socket_wait_all(socket_manager* mgr, int timeout) { socket_node* node = mgr->socket; int max_fd = 0; while(node) { - osrfLogInternal("Adding socket fd %d to select set",node->sock_fd); + osrfLogInternal( OSRF_LOG_MARK, "Adding socket fd %d to select set",node->sock_fd); FD_SET( node->sock_fd, &read_set ); if(node->sock_fd > max_fd) max_fd = node->sock_fd; node = node->next; @@ -487,21 +467,21 @@ int socket_wait_all(socket_manager* mgr, int timeout) { // If timeout is -1, there is no timeout passed to the call to select if( (retval = select( max_fd, &read_set, NULL, NULL, NULL)) == -1 ) { - osrfLogWarning("Call to select interrupted (returned -1)"); - osrfLogWarning("Sys Error: %s", strerror(errno)); + osrfLogWarning( OSRF_LOG_MARK, "Call to select interrupted (returned -1)"); + osrfLogWarning( OSRF_LOG_MARK, "Sys Error: %s", strerror(errno)); return -1; } } else if( timeout != 0 ) { /* timeout of 0 means don't block */ if( (retval = select( max_fd, &read_set, NULL, NULL, &tv)) == -1 ) { - osrfLogWarning( "Call to select interrupted (returned -1)" ); - osrfLogWarning("Sys Error: %s", strerror(errno)); + osrfLogWarning( OSRF_LOG_MARK, "Call to select interrupted (returned -1)" ); + osrfLogWarning( OSRF_LOG_MARK, "Sys Error: %s", strerror(errno)); return -1; } } - osrfLogDebug("%d active sockets after select()", retval); + osrfLogDebug( OSRF_LOG_MARK, "%d active sockets after select()", retval); return _socket_route_data(mgr, retval, &read_set); } @@ -528,7 +508,7 @@ int _socket_route_data( if(last_failed_id != -1) { /* in case it was not removed by our overlords */ - osrfLogInternal("Attempting to remove last_failed_id of %d", last_failed_id); + osrfLogInternal( OSRF_LOG_MARK, "Attempting to remove last_failed_id of %d", last_failed_id); socket_remove_node( mgr, last_failed_id ); last_failed_id = -1; status = -1; @@ -538,7 +518,7 @@ int _socket_route_data( /* does this socket have data? */ if( FD_ISSET( sock_fd, read_set ) ) { - osrfLogInternal("Socket %d active", sock_fd); + osrfLogInternal( OSRF_LOG_MARK, "Socket %d active", sock_fd); handled++; FD_CLR(sock_fd, read_set); @@ -552,7 +532,7 @@ int _socket_route_data( us...start over with the first socket */ if(status == -1) { last_failed_id = sock_fd; - osrfLogInternal("Backtracking back to start of loop because " + osrfLogInternal( OSRF_LOG_MARK, "Backtracking back to start of loop because " "of -1 return code from _socket_handle_client_data()"); } } @@ -595,17 +575,17 @@ int _socket_handle_new_client(socket_manager* mgr, socket_node* node) { int new_sock_fd; new_sock_fd = accept(node->sock_fd, NULL, NULL); if(new_sock_fd < 0) { - osrfLogWarning("_socket_route_data(): accept() failed"); + osrfLogWarning( OSRF_LOG_MARK, "_socket_route_data(): accept() failed"); return -1; } if(node->addr_type == INET) { _socket_add_node(mgr, CLIENT_SOCKET, INET, new_sock_fd, node->sock_fd); - osrfLogDebug("Adding new INET client for %d", node->sock_fd); + osrfLogDebug( OSRF_LOG_MARK, "Adding new INET client for %d", node->sock_fd); } else if(node->addr_type == UNIX) { _socket_add_node(mgr, CLIENT_SOCKET, UNIX, new_sock_fd, node->sock_fd); - osrfLogDebug("Adding new UNIX client for %d", node->sock_fd); + osrfLogDebug( OSRF_LOG_MARK, "Adding new UNIX client for %d", node->sock_fd); } return 0; @@ -622,10 +602,10 @@ int _socket_handle_client_data(socket_manager* mgr, socket_node* node) { memset(buf, 0, RBUFSIZE); set_fl(sock_fd, O_NONBLOCK); - osrfLogInternal("%d : Received data at %lf\n", getpid(), get_timestamp_millis()); + osrfLogInternal( OSRF_LOG_MARK, "%d : Received data at %lf\n", getpid(), get_timestamp_millis()); while( (read_bytes = recv(sock_fd, buf, RBUFSIZE-1, 0) ) > 0 ) { - osrfLogInternal("Socket %d Read %d bytes and data: %s", sock_fd, read_bytes, buf); + osrfLogInternal( OSRF_LOG_MARK, "Socket %d Read %d bytes and data: %s", sock_fd, read_bytes, buf); if(mgr->data_received) mgr->data_received(mgr->blob, mgr, sock_fd, buf, node->parent_id); @@ -636,7 +616,7 @@ int _socket_handle_client_data(socket_manager* mgr, socket_node* node) { clr_fl(sock_fd, O_NONBLOCK); if(read_bytes < 0) { if( errno != EAGAIN ) - osrfLogWarning( " * Error reading socket with errno %d", errno ); + osrfLogWarning( OSRF_LOG_MARK, " * Error reading socket with errno %d", errno ); } } else { return -1; } /* inform the caller that this node has been tampered with */ diff --git a/src/utils/string_array.c b/src/utils/string_array.c index 7f1ef7d..fcc2567 100644 --- a/src/utils/string_array.c +++ b/src/utils/string_array.c @@ -6,7 +6,7 @@ osrfStringArray* osrfNewStringArray(int size) { string_array* init_string_array(int size) { if(size > STRING_ARRAY_MAX_SIZE) - osrfLogError("init_string_array size is too large"); + osrfLogError( OSRF_LOG_MARK, "init_string_array size is too large"); string_array* arr = (string_array*) safe_malloc(sizeof(string_array)); @@ -28,7 +28,7 @@ void string_array_add(string_array* arr, char* str) { arr->size++; if( arr->size > STRING_ARRAY_MAX_SIZE ) - osrfLogError("string_array_add size is too large"); + osrfLogError( OSRF_LOG_MARK, "string_array_add size is too large"); /* if necessary, double capacity */ if(arr->size >= arr->arr_size) { -- 2.11.0