]> git.sur5r.net Git - openldap/commitdiff
Added LDAP_LOG messages
authorJulius Enarusai <julius@openldap.org>
Fri, 15 Mar 2002 18:57:12 +0000 (18:57 +0000)
committerJulius Enarusai <julius@openldap.org>
Fri, 15 Mar 2002 18:57:12 +0000 (18:57 +0000)
servers/slapd/back-bdb/idl.c

index f02c81a2073dfcbd6c045a5b1f85741270e23184..efc1a61a5497d46eabd445a4d3f4db1638afc722 100644 (file)
@@ -35,20 +35,35 @@ static void idl_check( ID *ids )
 static void idl_dump( ID *ids )
 {
        if( BDB_IDL_IS_RANGE( ids ) ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_INFO, "IDL: range (%ld - %ld)\n",
+                       (long) BDB_IDL_RANGE_FIRST( ids ),
+                       (long) BDB_IDL_RANGE_LAST( ids ) ));
+#else
                Debug( LDAP_DEBUG_ANY,
                        "IDL: range ( %ld - %ld )\n",
                        (long) BDB_IDL_RANGE_FIRST( ids ),
                        (long) BDB_IDL_RANGE_LAST( ids ) );
+#endif
 
        } else {
                ID i;
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_INFO, "IDL: size %ld",
+                       (long) ids[0] ));
+#else
                Debug( LDAP_DEBUG_ANY, "IDL: size %ld", (long) ids[0], 0, 0 );
+#endif
 
                for( i=1; i<=ids[0]; i++ ) {
                        if( i % 16 == 1 ) {
                                Debug( LDAP_DEBUG_ANY, "\n", 0, 0, 0 );
                        }
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "idl", LDAP_LEVEL_INFO, "%02lx",(long)ids[i] ));
+#else
                        Debug( LDAP_DEBUG_ANY, "  %02lx", (long) ids[i], 0, 0 );
+#endif
                }
 
                Debug( LDAP_DEBUG_ANY, "\n", 0, 0, 0 );
@@ -123,8 +138,13 @@ int bdb_idl_insert( ID *ids, ID id )
        unsigned x = bdb_idl_search( ids, id );
 
 #if IDL_DEBUG > 1
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "idl", LDAP_LEVEL_DETAIL1, "insert: %04lx at %d\n",
+                       (long) id, x ));
+#else
        Debug( LDAP_DEBUG_ANY, "insert: %04lx at %d\n", (long) id, x, 0 );
        idl_dump( ids );
+#endif
 #elif IDL_DEBUG > 0
        idl_check( ids );
 #endif
@@ -172,8 +192,13 @@ static int idl_delete( ID *ids, ID id )
        unsigned x = bdb_idl_search( ids, id );
 
 #if IDL_DEBUG > 1
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "idl", LDAP_LEVEL_DETAIL1, "delete: %04lx at %d\n",
+                       (long) id, x ));
+#else
        Debug( LDAP_DEBUG_ANY, "delete: %04lx at %d\n", (long) id, x, 0 );
        idl_dump( ids );
+#endif
 #elif IDL_DEBUG > 0
        idl_check( ids );
 #endif
@@ -241,8 +266,12 @@ bdb_idl_fetch_key(
 
                rc = db->cursor( db, tid, &cursor, bdb->bi_db_opflags );
                if( rc != 0 ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: cursor failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
                        Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
                                "cursor failed: %s (%d)\n", db_strerror(rc), rc, 0 );
+#endif
                        return rc;
                }
                rc = cursor->c_get( cursor, key, &data, flags | DB_SET );
@@ -266,9 +295,13 @@ bdb_idl_fetch_key(
                        /* On disk, a range is denoted by 0 in the first element */
                        if (ids[1] == 0) {
                                if (ids[0] != BDB_IDL_RANGE_SIZE) {
+#ifdef NEW_LOGGING
+                                       LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "=> bdb_idl_fetch_key: range size mismatch: expected %ld, got %ld\n", BDB_IDL_RANGE_SIZE, ids[0] ));
+#else
                                        Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
                                                "range size mismatch: expected %ld, got %ld\n",
                                                BDB_IDL_RANGE_SIZE, ids[0], 0 );
+#endif
                                        cursor->c_close( cursor );
                                        return -1;
                                }
@@ -278,8 +311,12 @@ bdb_idl_fetch_key(
                }
                rc2 = cursor->c_close( cursor );
                if (rc2) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: close failed: %s (%d)\n", db_strerror(rc2), rc2 ));
+#else
                        Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
-                               "close failed: %s (%d)\n", db_strerror(rc2), rc2, 0 );
+                               "close failed: %s (%d)\n", db_strerror(rc2), rc2, 0 )
+#endif
                        return rc2;
                }
        }
@@ -295,23 +332,35 @@ bdb_idl_fetch_key(
                return rc;
 
        } else if( rc != 0 ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: get failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
                        "get failed: %s (%d)\n",
                        db_strerror(rc), rc, 0 );
+#endif
                return rc;
 
        } else if ( data.size == 0 || data.size % sizeof( ID ) ) {
                /* size not multiple of ID size */
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: odd size: expected %ld multiple, got %ld\n", (long) sizeof( ID ), (long) data.size ));
+#else
                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
                        "odd size: expected %ld multiple, got %ld\n",
                        (long) sizeof( ID ), (long) data.size, 0 );
+#endif
                return -1;
 
        } else if ( data.size != BDB_IDL_SIZEOF(ids) ) {
                /* size mismatch */
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: get size mismatch: expected %ld, got %ld\n", (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size ));
+#else
                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
                        "get size mismatch: expected %ld, got %ld\n",
                        (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size, 0 );
+#endif
                return -1;
        }
 
@@ -335,9 +384,13 @@ bdb_idl_insert_key(
 
 #if 0
        /* for printable keys only */
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "idl", LDAP_LEVEL_ARGS, "bdb_idl_insert_key: %s %ld\n", (char *)key->data, (long) id ));
+#else
        Debug( LDAP_DEBUG_ARGS,
                "=> bdb_idl_insert_key: %s %ld\n",
                (char *)key->data, (long) id, 0 );
+#endif
 #endif
 
        assert( id != NOID );
@@ -373,8 +426,12 @@ bdb_idl_insert_key(
                                id > BDB_IDL_RANGE_LAST(buf) ) {
                                rc = db->cursor( db, tid, &cursor, bdb->bi_db_opflags );
                                if ( rc != 0 ) {
+#ifdef NEW_LOGGING
+                                       LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: cursor failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
                                        Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
                                                "cursor failed: %s (%d)\n", db_strerror(rc), rc, 0 );
+#endif
                                        return rc;
                                }
                                if ( id < BDB_IDL_RANGE_FIRST(buf) ) {
@@ -385,8 +442,13 @@ bdb_idl_insert_key(
                                rc = cursor->c_get( cursor, key, &data, DB_GET_BOTH | DB_RMW );
                                if ( rc != 0 ) {
                                        err = "c_get";
-fail:                          Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
+fail:
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: %s failed: %s (%d)\n", err, db_strerror(rc), rc ));
+#else
+                               Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
                                                "%s failed: %s (%d)\n", err, db_strerror(rc), rc );
+#endif
                                        if ( cursor ) cursor->c_close( cursor );
                                        return rc;
                                }
@@ -466,23 +528,35 @@ fail:                             Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
                data.size = 2 * sizeof( ID );
 
        } else if ( rc != 0 ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: get failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
                        "get failed: %s (%d)\n",
                        db_strerror(rc), rc, 0 );
+#endif
                return rc;
 
        } else if ( data.size == 0 || data.size % sizeof( ID ) ) {
                /* size not multiple of ID size */
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: odd size: expected %ld multiple, got %ld\n", (long) sizeof( ID ), (long) data.size ));
+#else
                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
                        "odd size: expected %ld multiple, got %ld\n",
                        (long) sizeof( ID ), (long) data.size, 0 );
+#endif
                return -1;
        
        } else if ( data.size != BDB_IDL_SIZEOF(ids) ) {
                /* size mismatch */
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: odd size: expected %ld multiple, got %ld\n", (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size ));
+#else
                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
                        "get size mismatch: expected %ld, got %ld\n",
                        (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size, 0 );
+#endif
                return -1;
 
        } else if ( BDB_IDL_IS_RANGE(ids) ) {
@@ -498,14 +572,22 @@ fail:                             Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
                rc = bdb_idl_insert( ids, id );
 
                if( rc == -1 ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "idl", LDAP_LEVEL_DETAIL1, "bdb_idl_insert_key: dup\n" ));
+#else
                        Debug( LDAP_DEBUG_TRACE, "=> bdb_idl_insert_key: dup\n",
                                0, 0, 0 );
+#endif
                        return 0;
                }
                if( rc != 0 ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: insert failed: (%d)\n", rc ));
+#else
                        Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
                                "bdb_idl_insert failed (%d)\n",
                                rc, 0, 0 );
+#endif
                        
                        return rc;
                }
@@ -519,9 +601,13 @@ fail:                              Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
        if( rc == DB_KEYEXIST ) rc = 0;
 
        if( rc != 0 ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: put failed: (%d)\n", db_strerror(rc), rc ));
+#else
                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
                        "put failed: %s (%d)\n",
                        db_strerror(rc), rc, 0 );
+#endif
        }
        return rc;
 }
@@ -543,9 +629,13 @@ bdb_idl_delete_key(
 
 #if 0
        /* for printable keys only */
+#ifdef NEW_LOGGING
+       LDAP_LOG(( "idl", LDAP_LEVEL_ARGS, "bdb_idl_delete_key: %s %ld\n", (char *)key->data, (long) id ));
+#else
        Debug( LDAP_DEBUG_ARGS,
                "=> bdb_idl_delete_key: %s %ld\n",
                (char *)key->data, (long) id, 0 );
+#endif
 #endif
 
        assert( id != NOID );
@@ -576,16 +666,24 @@ bdb_idl_delete_key(
        rc = db->get( db, tid, key, &data, DB_RMW | bdb->bi_db_opflags );
 
        if ( rc != 0 ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: get failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: "
                        "get failed: %s (%d)\n",
                        db_strerror(rc), rc, 0 );
+#endif
                return rc;
 
        } else if ( data.size == 0 || data.size % sizeof( ID ) ) {
                /* size not multiple of ID size */
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: odd size: expected: %ld multiple, got %ld\n", (long) sizeof( ID ), (long) data.size ));
+#else
                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: "
                        "odd size: expected %ld multiple, got %ld\n",
                        (long) sizeof( ID ), (long) data.size, 0 );
+#endif
                return -1;
        
        } else if ( BDB_IDL_IS_RANGE(ids) ) {
@@ -593,18 +691,26 @@ bdb_idl_delete_key(
 
        } else if ( data.size != (1 + ids[0]) * sizeof( ID ) ) {
                /* size mismatch */
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: get size mismatch: expected: %ld, got %ld\n", (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size ));
+#else
                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: "
                        "get size mismatch: expected %ld, got %ld\n",
                        (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size, 0 );
+#endif
                return -1;
 
        } else {
                rc = idl_delete( ids, id );
 
                if( rc != 0 ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: delete failed: (%d)\n", rc ));
+#else
                        Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: "
                                "idl_delete failed (%d)\n",
                                rc, 0, 0 );
+#endif
                        return rc;
                }
 
@@ -612,9 +718,13 @@ bdb_idl_delete_key(
                        /* delete the key */
                        rc = db->del( db, tid, key, 0 );
                        if( rc != 0 ) {
+#ifdef NEW_LOGGING
+                               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: delete failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
                                Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: "
                                        "delete failed: %s (%d)\n",
                                        db_strerror(rc), rc, 0 );
+#endif
                        }
                        return rc;
                }
@@ -628,9 +738,13 @@ bdb_idl_delete_key(
 #endif /* BDB_IDL_MULTI */
 
        if( rc != 0 ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: put failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
                Debug( LDAP_DEBUG_ANY,
                        "=> bdb_idl_delete_key: put failed: %s (%d)\n",
                        db_strerror(rc), rc, 0 );
+#endif
        }
 
        return rc;