]> git.sur5r.net Git - openldap/commitdiff
Added LDAP_LOG messages
authorJulius Enarusai <julius@openldap.org>
Wed, 27 Mar 2002 18:20:08 +0000 (18:20 +0000)
committerJulius Enarusai <julius@openldap.org>
Wed, 27 Mar 2002 18:20:08 +0000 (18:20 +0000)
libraries/libldap/abandon.c
libraries/libldap/add.c
libraries/libldap/bind.c
libraries/libldap/cache.c

index 521f2d524255040939bc03ba27c30596dad62dbe..70c2d97e732879709e9beae901f9bc3bed22907a 100644 (file)
@@ -57,7 +57,11 @@ ldap_abandon_ext(
        LDAPControl **cctrls )
 {
        int rc;
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "abandon", LDAP_LEVEL_ARGS, "ldap_abandon_ext %d\n", msgid ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 );
+#endif
 
        /* check client controls */
        rc = ldap_int_client_controls( ld, cctrls );
@@ -81,7 +85,11 @@ ldap_abandon_ext(
 int
 ldap_abandon( LDAP *ld, int msgid )
 {
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "abandon", LDAP_LEVEL_ARGS, "ldap_abandon %d\n", msgid ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_abandon %d\n", msgid, 0, 0 );
+#endif
        return ldap_abandon_ext( ld, msgid, NULL, NULL ) == LDAP_SUCCESS
                ? 0 : -1;
 }
@@ -101,8 +109,13 @@ do_abandon(
        Sockbuf         *sb;
        LDAPRequest     *lr;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "abandon", LDAP_LEVEL_ARGS, "do_abandon %d, msgid %d\n", 
+               origid, msgid ));
+#else
        Debug( LDAP_DEBUG_TRACE, "do_abandon origid %d, msgid %d\n",
                origid, msgid, 0 );
+#endif
 
        sendabandon = 1;
 
index d850ba73294aaf0221b48934fdee19548507c988..1ce57eba7f6f95d4fa09a3796ea268aa5f8febf1 100644 (file)
@@ -99,7 +99,11 @@ ldap_add_ext(
        BerElement      *ber;
        int             i, rc;
 
-       Debug( LDAP_DEBUG_TRACE, "ldap_add\n", 0, 0, 0 );
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "add", LDAP_LEVEL_ENTRY, "ldap_add_ext\n" ));
+#else
+       Debug( LDAP_DEBUG_TRACE, "ldap_add_ext\n", 0, 0, 0 );
+#endif
        assert( ld != NULL );
        assert( LDAP_VALID( ld ) );
        assert( dn != NULL );
index ca6e3a10c6bf965d7b65e3c939fbfe671686f858..076bd179768d085e85a416848986c6657c6d7c46 100644 (file)
 int
 ldap_bind( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd, int authmethod )
 {
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "bind", LDAP_LEVEL_ENTRY, "ldap_bind\n" ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_bind\n", 0, 0, 0 );
+#endif
 
        switch ( authmethod ) {
        case LDAP_AUTH_SIMPLE:
@@ -105,7 +109,11 @@ ldap_bind_s(
        LDAP_CONST char *passwd,
        int authmethod )
 {
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "bind", LDAP_LEVEL_ENTRY, "ldap_bind_s\n" ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_bind_s\n", 0, 0, 0 );
+#endif
 
        switch ( authmethod ) {
        case LDAP_AUTH_SIMPLE:
index b839bf7f757a50ef1a6d9e7859e2faa633602aff..3f56e18b80f15232ffc41e8c13f5e47397829e4d 100644 (file)
@@ -102,7 +102,11 @@ ldap_flush_cache( LDAP *ld )
        int             i;
        LDAPMessage     *m, *next;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_flush_cache\n" ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_flush_cache\n", 0, 0, 0 );
+#endif
 
        if ( ld->ld_cache != NULL ) {
                /* delete all requests in the queue */
@@ -131,8 +135,14 @@ void
 ldap_uncache_request( LDAP *ld, int msgid )
 {
 #ifndef LDAP_NOCACHE
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, 
+               "ldap_uncache_request %d ld_cache %lx\n",
+               msgid, (long) ld->ld_cache ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_uncache_request %d ld_cache %lx\n",
            msgid, (long) ld->ld_cache, 0 );
+#endif
 
        uncache_entry_or_req( ld, NULL, msgid );
 #endif
@@ -143,8 +153,14 @@ void
 ldap_uncache_entry( LDAP *ld, LDAP_CONST char *dn )
 {
 #ifndef LDAP_NOCACHE
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, 
+               "ldap_uncache_entry %s ld_cache %lx\n",
+               dn, (long) ld->ld_cache ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_uncache_entry %s ld_cache %lx\n",
            dn, (long) ld->ld_cache, 0 );
+#endif
 
        uncache_entry_or_req( ld, dn, 0 );
 #endif
@@ -161,9 +177,15 @@ uncache_entry_or_req( LDAP *ld,
        int             i;
        LDAPMessage     *m, *prev, *next;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, 
+               "uncache_entry_or_req dn %s msgid %ld ld_cache %lx\n",
+               dn, (long) msgid, (long) ld->ld_cache ));
+#else
        Debug( LDAP_DEBUG_TRACE,
            "ldap_uncache_entry_or_req  dn %s  msgid %ld  ld_cache %lx\n",
            dn, (long) msgid, (long) ld->ld_cache );
+#endif
 
        if ( ld->ld_cache == NULL ) {
            return;
@@ -218,7 +240,11 @@ ldap_add_request_to_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
        LDAPMessage     *new;
        ber_len_t       len;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_add_request_to_cache\n" ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_add_request_to_cache\n", 0, 0, 0 );
+#endif
 
        ld->ld_errno = LDAP_SUCCESS;
        if ( ld->ld_cache == NULL ||
@@ -262,12 +288,23 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result )
        LDAPMessage     *m, **mp, *req, *new, *prev;
        int             err, keep;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_ARGS, 
+               "ldap_add_result_to_cache: id %ld, type %ld\n",
+               (long) result->lm_msgid, (long) result->lm_msgtype ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_add_result_to_cache: id %ld, type %ld\n", 
                (long) result->lm_msgid, (long) result->lm_msgtype, 0 );
+#endif
 
        if ( ld->ld_cache == NULL ||
            ( ld->ld_cache->lc_enabled == 0 )) {
+#ifdef NEW_LOGGING
+               LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, 
+               "ldap_add_result_to_cache: cache disabled\n" ));
+#else
                Debug( LDAP_DEBUG_TRACE, "artc: cache disabled\n", 0, 0, 0 );
+#endif
                return;
        }
 
@@ -278,8 +315,14 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result )
                /*
                 * only cache search and compare operations
                 */
+#ifdef NEW_LOGGING
+               LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, 
+               "ldap_add_result_to_cache: "
+               "only caching search & compare operations\n" ));
+#else
                Debug( LDAP_DEBUG_TRACE,
                    "artc: only caching search & compare operations\n", 0, 0, 0 );
+#endif
                return;
        }
 
@@ -303,9 +346,15 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result )
                if (( new = msg_dup( result )) != NULL ) {
                        new->lm_chain = NULL;
                        m->lm_chain = new;
+#ifdef NEW_LOGGING
+                       LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, 
+                               "ldap_add_result_to_cache: "
+                               "result added to cache request chain\n" ));
+#else
                        Debug( LDAP_DEBUG_TRACE,
                            "artc: result added to cache request chain\n",
                            0, 0, 0 );
+#endif
                }
                if ( result->lm_msgtype == LDAP_RES_SEARCH_RESULT ||
                    result->lm_msgtype == LDAP_RES_COMPARE ) {
@@ -339,9 +388,15 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result )
                        }
 
                        if ( !keep ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, 
+                                       "ldap_add_result_to_cache: "
+                                       "not caching result with error\n" ));
+#else
                                Debug( LDAP_DEBUG_TRACE,
                                    "artc: not caching result with error %d\n",
                                    err, 0, 0 );
+#endif
                                ldap_msgfree( req );
                        } else {
                                mp = &ld->ld_cache->lc_buckets[
@@ -351,14 +406,26 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result )
                                req->lm_time = (long) time( NULL );
                                ld->ld_cache->lc_memused += msg_size( req );
                                check_cache_memused( ld->ld_cache );
+#ifdef NEW_LOGGING
+                               LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, 
+                                       "ldap_add_result_to_cache: "
+                                       "cached result with error\n" ));
+#else
                                Debug( LDAP_DEBUG_TRACE,
                                    "artc: cached result with error %d\n",
                                    err, 0, 0 );
+#endif
                        }
                }
        } else {
+#ifdef NEW_LOGGING
+               LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, 
+                       "ldap_add_result_to_cache: "
+                       "msgid not in request list\n" ));
+#else
                Debug( LDAP_DEBUG_TRACE, "artc: msgid not in request list\n",
                    0, 0, 0 );
+#endif
        }
 #endif
 }
@@ -380,7 +447,11 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
        int             first, hash;
        time_t  c_time;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_ENTRY, "ldap_check_cache\n" ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_check_cache\n", 0, 0, 0 );
+#endif
 
        if ( ld->ld_cache == NULL ||
            ( ld->ld_cache->lc_enabled == 0 )) {
@@ -398,8 +469,14 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
        prev = NULL;
        hash = cache_hash( &reqber );
        for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULL; m = next ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, 
+                       "ldap_check_cache: examining id %ld, type %ld\n",
+                       (long) m->lm_msgid, (long) m->lm_msgtype ));
+#else
                Debug( LDAP_DEBUG_TRACE,"cc: examining id %ld,type %ld\n",
                    (long) m->lm_msgid, (long) m->lm_msgtype, 0 );
+#endif
                if ( difftime(c_time, m->lm_time) > ld->ld_cache->lc_timeout ) {
                        /* delete expired message */
                        next = m->lm_next;
@@ -408,8 +485,14 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
                        } else {
                                prev->lm_next = next;
                        }
+#ifdef NEW_LOGGING
+                       LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, 
+                               "ldap_check_cache: expired id %ld\n",
+                               (long) m->lm_msgid ));
+#else
                        Debug( LDAP_DEBUG_TRACE, "cc: expired id %d\n",
                            m->lm_msgid, 0, 0 );
+#endif
                        ld->ld_cache->lc_memused -= msg_size( m );
                        ldap_msgfree( m );
                } else {
@@ -445,11 +528,22 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
                        prev->lm_chain = new;
                }
                prev = new;
+#ifdef NEW_LOGGING
+               LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, 
+                       "ldap_check_cache: added type %ld\n",
+                       (long) m->lm_msgtype ));
+#else
                Debug( LDAP_DEBUG_TRACE, "cc: added type %ld\n",
                    (long) new->lm_msgtype, 0, 0 );
+#endif
        }
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, 
+               "ldap_check_cache: result returned from cache\n" ));
+#else
        Debug( LDAP_DEBUG_TRACE, "cc: result returned from cache\n", 0, 0, 0 );
+#endif
        return( 0 );
 #else
        return( -1 );
@@ -475,8 +569,14 @@ cache_hash( BerElement *ber )
            len = bercpy.ber_end - bercpy.ber_ptr;
        }
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_RESULTS, 
+               "cache_hash: len is %ld, returning %ld\n",
+                len, len % LDAP_CACHE_BUCKETS ));
+#else
        Debug( LDAP_DEBUG_TRACE, "cache_hash: len is %ld, returning %ld\n",
            len, len % LDAP_CACHE_BUCKETS, 0 );
+#endif
        return( (int) ( len % LDAP_CACHE_BUCKETS ));
 }
 
@@ -626,8 +726,14 @@ check_cache_memused( LDAPCache *lc )
        time_t c_time;
        LDAPMessage     *m, *prev, *next;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, 
+               "check_cache_memused: %ld bytes in use (%ld max)\n",
+                lc->lc_memused, lc->lc_maxmem ));
+#else
        Debug( LDAP_DEBUG_TRACE, "check_cache_memused: %ld bytes in use (%ld max)\n",
            lc->lc_memused, lc->lc_maxmem, 0 );
+#endif
 
        if ( (unsigned) lc->lc_maxmem <= sizeof( LDAPCache )
            || lc->lc_memused <= lc->lc_maxmem * SIZE_FACTOR ) {
@@ -649,9 +755,15 @@ check_cache_memused( LDAPCache *lc )
                                                prev->lm_next = next;
                                        }
                                        lc->lc_memused -= msg_size( m );
+#ifdef NEW_LOGGING
+                                       LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, 
+                                               "check_cache_memused: removed %ld\n",
+                                               m->lm_msgid ));
+#else
                                        Debug( LDAP_DEBUG_TRACE,
                                            "ccm: removed %d\n",
                                            m->lm_msgid, 0, 0 );
+#endif
                                        ldap_msgfree( m );
                                } else {
                                        prev = m;
@@ -661,8 +773,14 @@ check_cache_memused( LDAPCache *lc )
                remove_threshold *= THRESHOLD_FACTOR;
        }
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "cache", LDAP_LEVEL_DETAIL1, 
+               "check_cache_memused: reduced usage to %ld bytes\n",
+               lc->lm_memused ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ccm: reduced usage to %ld bytes\n",
            lc->lc_memused, 0, 0 );
+#endif
 }
 
 #endif /* !NO_CACHE */