1 /* trace.c - traces overlay invocation */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2006 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Pierangelo Masarati for inclusion in
23 #ifdef SLAPD_OVER_TRACE
27 #include <ac/string.h>
28 #include <ac/socket.h>
34 trace_op2str( Operation *op, char **op_strp, char **op_oidp )
38 switch ( op->o_tag ) {
67 case LDAP_REQ_COMPARE:
71 case LDAP_REQ_ABANDON:
75 case LDAP_REQ_EXTENDED:
76 *op_strp = "EXTENDED";
77 *op_oidp = op->ore_reqoid.bv_val;
88 trace_op_func( Operation *op, SlapReply *rs )
93 (void)trace_op2str( op, &op_str, &op_oid );
95 Log4( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
96 "%s trace op=%s oid=%s dn=\"%s\"\n",
97 op->o_log_prefix, op_str, op_oid,
98 BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val );
100 return SLAP_CB_CONTINUE;
104 trace_response( Operation *op, SlapReply *rs )
109 (void)trace_op2str( op, &op_str, &op_oid );
111 Log5( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
112 "%s trace op=%s RESPONSE oid=%s dn=\"%s\" err=%d\n",
113 op->o_log_prefix, op_str, op_oid,
114 BER_BVISNULL( &op->o_req_ndn ) ? "(null)" : op->o_req_ndn.bv_val,
117 return SLAP_CB_CONTINUE;
124 Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
138 Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
139 "trace DB_CONFIG argc=%d argv[0]=\"%s\"\n",
149 Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
159 Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
160 "trace DB_CLOSE\n" );
169 Log0( LDAP_DEBUG_ANY, LDAP_LEVEL_INFO,
170 "trace DB_DESTROY\n" );
175 static slap_overinst trace;
180 trace.on_bi.bi_type = "trace";
182 trace.on_bi.bi_db_init = trace_db_init;
183 trace.on_bi.bi_db_open = trace_db_open;
184 trace.on_bi.bi_db_config = trace_db_config;
185 trace.on_bi.bi_db_close = trace_db_close;
186 trace.on_bi.bi_db_destroy = trace_db_destroy;
188 trace.on_bi.bi_op_add = trace_op_func;
189 trace.on_bi.bi_op_bind = trace_op_func;
190 trace.on_bi.bi_op_unbind = trace_op_func;
191 trace.on_bi.bi_op_compare = trace_op_func;
192 trace.on_bi.bi_op_delete = trace_op_func;
193 trace.on_bi.bi_op_modify = trace_op_func;
194 trace.on_bi.bi_op_modrdn = trace_op_func;
195 trace.on_bi.bi_op_search = trace_op_func;
196 trace.on_bi.bi_op_abandon = trace_op_func;
197 trace.on_bi.bi_extended = trace_op_func;
199 trace.on_response = trace_response;
201 return overlay_register( &trace );
204 #if SLAPD_OVER_TRACE == SLAPD_MOD_DYNAMIC
206 init_module( int argc, char *argv[] )
208 return trace_initialize();
210 #endif /* SLAPD_OVER_TRACE == SLAPD_MOD_DYNAMIC */
212 #endif /* defined(SLAPD_OVER_TRACE) */