From: Pierangelo Masarati Date: Sat, 14 Jan 2006 18:59:46 +0000 (+0000) Subject: improve logging X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~306 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4d9fc0e85dc9b1edb84de212156293a282a4e041;p=openldap improve logging --- diff --git a/contrib/slapd-modules/trace/trace.c b/contrib/slapd-modules/trace/trace.c index c4dfdb22ff..7fdbc8c0eb 100644 --- a/contrib/slapd-modules/trace/trace.c +++ b/contrib/slapd-modules/trace/trace.c @@ -31,10 +31,8 @@ #include "lutil.h" static int -trace_op2str( Operation *op, char **op_strp, char **op_oidp ) +trace_op2str( Operation *op, char **op_strp ) { - *op_oidp = ""; - switch ( op->o_tag ) { case LDAP_REQ_BIND: *op_strp = "BIND"; @@ -74,7 +72,6 @@ trace_op2str( Operation *op, char **op_strp, char **op_oidp ) case LDAP_REQ_EXTENDED: *op_strp = "EXTENDED"; - *op_oidp = op->ore_reqoid.bv_val; break; default: @@ -88,14 +85,25 @@ static int trace_op_func( Operation *op, SlapReply *rs ) { char *op_str = NULL; - char *op_oid = ""; - (void)trace_op2str( op, &op_str, &op_oid ); + (void)trace_op2str( op, &op_str ); - Log4( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, - "%s trace op=%s oid=%s dn=\"%s\"\n", - op->o_log_prefix, op_str, op_oid, - BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val ); + switch ( op->o_tag ) { + case LDAP_REQ_EXTENDED: + Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, + "%s trace op=EXTENDED dn=\"%s\" reqoid=%s\n", + op->o_log_prefix, + BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val, + BER_BVISNULL( &op->ore_reqoid ) ? "" : op->ore_reqoid.bv_val ); + break; + + default: + Log3( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, + "%s trace op=%s dn=\"%s\"\n", + op->o_log_prefix, op_str, + BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val ); + break; + } return SLAP_CB_CONTINUE; } @@ -104,16 +112,55 @@ static int trace_response( Operation *op, SlapReply *rs ) { char *op_str = NULL; - char *op_oid = ""; - (void)trace_op2str( op, &op_str, &op_oid ); + (void)trace_op2str( op, &op_str ); - Log5( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, - "%s trace op=%s RESPONSE oid=%s dn=\"%s\" err=%d\n", - op->o_log_prefix, op_str, op_oid, - BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val, - rs->sr_err ); + switch ( op->o_tag ) { + case LDAP_REQ_EXTENDED: + Log5( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, + "%s trace op=EXTENDED RESPONSE dn=\"%s\" reqoid=%s rspoid=%s err=%d\n", + op->o_log_prefix, + BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val, + BER_BVISNULL( &op->ore_reqoid ) ? "" : op->ore_reqoid.bv_val, + rs->sr_rspoid == NULL ? "" : rs->sr_rspoid, + rs->sr_err ); + break; + + case LDAP_REQ_SEARCH: + switch ( rs->sr_type ) { + case REP_SEARCH: + Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, + "%s trace op=SEARCH ENTRY dn=\"%s\"\n", + op->o_log_prefix, + rs->sr_entry->e_name.bv_val ); + goto done; + + case REP_SEARCHREF: + Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, + "%s trace op=SEARCH REFERENCE ref=\"%s\"\n", + op->o_log_prefix, + rs->sr_ref[ 0 ].bv_val ); + goto done; + + case REP_RESULT: + break; + + default: + assert( 0 ); + } + /* fallthru */ + + default: + Log4( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO, + "%s trace op=%s RESPONSE dn=\"%s\" err=%d\n", + op->o_log_prefix, + op_str, + BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val, + rs->sr_err ); + break; + } +done:; return SLAP_CB_CONTINUE; }