ctdb-recovery: Log messages at various debug levels
authorAmitay Isaacs <amitay@gmail.com>
Thu, 8 Jun 2017 08:22:17 +0000 (18:22 +1000)
committerMartin Schwenke <martins@samba.org>
Tue, 13 Jun 2017 11:22:09 +0000 (13:22 +0200)
This avoids spamming the logs during recovery at NOTICE level.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Jun 13 13:22:09 CEST 2017 on sn-devel-144

ctdb/server/ctdb_recovery_helper.c

index 0222aa0bacde27645e7ded31ad81f8b4b49b91c5..ab5dccc0fa038d312c8ef16d12c0c5c8d295e86d 100644 (file)
@@ -43,8 +43,6 @@ static int recover_timeout = 30;
 
 #define TIMEOUT()      timeval_current_ofs(recover_timeout, 0)
 
-#define LOG(...)       DEBUG(DEBUG_NOTICE, (__VA_ARGS__))
-
 /*
  * Utility functions
  */
@@ -119,7 +117,7 @@ static struct recdb_context *recdb_create(TALLOC_CTX *mem_ctx, uint32_t db_id,
                                  tdb_flags, O_RDWR|O_CREAT|O_EXCL, 0600);
        if (recdb->db == NULL) {
                talloc_free(recdb);
-               LOG("failed to create recovery db %s\n", recdb->db_path);
+               D_ERR("failed to create recovery db %s\n", recdb->db_path);
                return NULL;
        }
 
@@ -316,8 +314,8 @@ static struct ctdb_rec_buffer *recdb_records(struct recdb_context *recdb,
        ret = tdb_traverse_read(recdb_tdb(recdb), recdb_records_traverse,
                                &state);
        if (ret == -1 || state.failed) {
-               LOG("Failed to marshall recovery records for %s\n",
-                   recdb_name(recdb));
+               D_ERR("Failed to marshall recovery records for %s\n",
+                     recdb_name(recdb));
                TALLOC_FREE(state.recbuf);
                return NULL;
        }
@@ -356,8 +354,8 @@ static int recdb_file_traverse(struct tdb_context *tdb,
        if (ctdb_rec_buffer_len(state->recbuf) > state->max_size) {
                ret = ctdb_rec_buffer_write(state->recbuf, state->fd);
                if (ret != 0) {
-                       LOG("Failed to collect recovery records for %s\n",
-                           recdb_name(state->recdb));
+                       D_ERR("Failed to collect recovery records for %s\n",
+                             recdb_name(state->recdb));
                        state->failed = true;
                        return ret;
                }
@@ -404,15 +402,15 @@ static int recdb_file(struct recdb_context *recdb, TALLOC_CTX *mem_ctx,
 
        ret = ctdb_rec_buffer_write(state.recbuf, fd);
        if (ret != 0) {
-               LOG("Failed to collect recovery records for %s\n",
-                   recdb_name(recdb));
+               D_ERR("Failed to collect recovery records for %s\n",
+                     recdb_name(recdb));
                TALLOC_FREE(state.recbuf);
                return -1;
        }
        state.num_buffers += 1;
 
-       LOG("Wrote %d buffers of recovery records for %s\n",
-           state.num_buffers, recdb_name(recdb));
+       D_DEBUG("Wrote %d buffers of recovery records for %s\n",
+               state.num_buffers, recdb_name(recdb));
 
        return state.num_buffers;
 }
@@ -508,14 +506,14 @@ static void pull_database_handler(uint64_t srvid, TDB_DATA data,
 
        ret = ctdb_rec_buffer_pull(data.dptr, data.dsize, state, &recbuf);
        if (ret != 0) {
-               LOG("Invalid data received for DB_PULL messages\n");
+               D_ERR("Invalid data received for DB_PULL messages\n");
                return;
        }
 
        if (recbuf->db_id != recdb_id(state->recdb)) {
                talloc_free(recbuf);
-               LOG("Invalid dbid:%08x for DB_PULL messages for %s\n",
-                   recbuf->db_id, recdb_name(state->recdb));
+               D_ERR("Invalid dbid:%08x for DB_PULL messages for %s\n",
+                     recbuf->db_id, recdb_name(state->recdb));
                return;
        }
 
@@ -523,8 +521,8 @@ static void pull_database_handler(uint64_t srvid, TDB_DATA data,
                           recbuf);
        if (! status) {
                talloc_free(recbuf);
-               LOG("Failed to add records to recdb for %s\n",
-                   recdb_name(state->recdb));
+               D_ERR("Failed to add records to recdb for %s\n",
+                     recdb_name(state->recdb));
                return;
        }
 
@@ -546,8 +544,8 @@ static void pull_database_register_done(struct tevent_req *subreq)
        status = ctdb_client_set_message_handler_recv(subreq, &ret);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("failed to set message handler for DB_PULL for %s\n",
-                   recdb_name(state->recdb));
+               D_ERR("Failed to set message handler for DB_PULL for %s\n",
+                     recdb_name(state->recdb));
                tevent_req_error(req, ret);
                return;
        }
@@ -579,8 +577,8 @@ static void pull_database_old_done(struct tevent_req *subreq)
        status = ctdb_client_control_recv(subreq, &ret, state, &reply);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("control PULL_DB failed for %s on node %u, ret=%d\n",
-                   recdb_name(state->recdb), state->pnn, ret);
+               D_ERR("control PULL_DB failed for %s on node %u, ret=%d\n",
+                     recdb_name(state->recdb), state->pnn, ret);
                tevent_req_error(req, ret);
                return;
        }
@@ -603,8 +601,8 @@ static void pull_database_old_done(struct tevent_req *subreq)
        state->num_records = recbuf->count;
        talloc_free(recbuf);
 
-       LOG("Pulled %d records for db %s from node %d\n",
-           state->num_records, recdb_name(state->recdb), state->pnn);
+       D_INFO("Pulled %d records for db %s from node %d\n",
+              state->num_records, recdb_name(state->recdb), state->pnn);
 
        tevent_req_done(req);
 }
@@ -623,8 +621,8 @@ static void pull_database_new_done(struct tevent_req *subreq)
        status = ctdb_client_control_recv(subreq, &ret, state, &reply);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("control DB_PULL failed for %s on node %u, ret=%d\n",
-                   recdb_name(state->recdb), state->pnn, ret);
+               D_ERR("control DB_PULL failed for %s on node %u, ret=%d\n",
+                     recdb_name(state->recdb), state->pnn, ret);
                tevent_req_error(req, ret);
                return;
        }
@@ -632,14 +630,15 @@ static void pull_database_new_done(struct tevent_req *subreq)
        ret = ctdb_reply_control_db_pull(reply, &num_records);
        talloc_free(reply);
        if (num_records != state->num_records) {
-               LOG("mismatch (%u != %u) in DB_PULL records for %s\n",
-                   num_records, state->num_records, recdb_name(state->recdb));
+               D_ERR("mismatch (%u != %u) in DB_PULL records for db %s\n",
+                     num_records, state->num_records,
+                     recdb_name(state->recdb));
                tevent_req_error(req, EIO);
                return;
        }
 
-       LOG("Pulled %d records for db %s from node %d\n",
-           state->num_records, recdb_name(state->recdb), state->pnn);
+       D_INFO("Pulled %d records for db %s from node %d\n",
+              state->num_records, recdb_name(state->recdb), state->pnn);
 
        subreq = ctdb_client_remove_message_handler_send(
                                        state, state->ev, state->client,
@@ -662,8 +661,8 @@ static void pull_database_unregister_done(struct tevent_req *subreq)
        status = ctdb_client_remove_message_handler_recv(subreq, &ret);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("failed to remove message handler for DB_PULL for %s\n",
-                   recdb_name(state->recdb));
+               D_ERR("failed to remove message handler for DB_PULL for db %s\n",
+                     recdb_name(state->recdb));
                tevent_req_error(req, ret);
                return;
        }
@@ -750,9 +749,9 @@ static void push_database_old_push_done(struct tevent_req *subreq)
        status = ctdb_client_control_recv(subreq, &ret, NULL, NULL);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("control PUSH_DB failed for db %s on node %u, ret=%d\n",
-                   recdb_name(state->recdb), state->pnn_list[state->index],
-                   ret);
+               D_ERR("control PUSH_DB failed for db %s on node %u, ret=%d\n",
+                     recdb_name(state->recdb), state->pnn_list[state->index],
+                     ret);
                tevent_req_error(req, ret);
                return;
        }
@@ -897,12 +896,13 @@ static void push_database_new_started(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("control DB_PUSH_START failed for db %s "
-                           "on node %u, ret=%d\n",
-                           recdb_name(state->recdb), pnn, ret2);
+                       D_ERR("control DB_PUSH_START failed for db %s"
+                             " on node %u, ret=%d\n",
+                             recdb_name(state->recdb), pnn, ret2);
                } else {
-                       LOG("control DB_PUSH_START failed for db %s, ret=%d\n",
-                           recdb_name(state->recdb), ret);
+                       D_ERR("control DB_PUSH_START failed for db %s,"
+                             " ret=%d\n",
+                             recdb_name(state->recdb), ret);
                }
                talloc_free(err_list);
 
@@ -958,8 +958,9 @@ static void push_database_new_send_msg(struct tevent_req *req)
        message.srvid = state->srvid;
        message.data.data = data;
 
-       LOG("Pushing buffer %d with %d records for %s\n",
-           state->num_buffers_sent, recbuf->count, recdb_name(state->recdb));
+       D_DEBUG("Pushing buffer %d with %d records for db %s\n",
+               state->num_buffers_sent, recbuf->count,
+               recdb_name(state->recdb));
 
        subreq = ctdb_client_message_multi_send(state, state->ev,
                                                state->client,
@@ -988,8 +989,8 @@ static void push_database_new_send_done(struct tevent_req *subreq)
        status = ctdb_client_message_multi_recv(subreq, &ret, NULL, NULL);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("Sending recovery records failed for %s\n",
-                   recdb_name(state->recdb));
+               D_ERR("Sending recovery records failed for %s\n",
+                     recdb_name(state->recdb));
                tevent_req_error(req, ret);
                return;
        }
@@ -1022,11 +1023,13 @@ static void push_database_new_confirmed(struct tevent_req *subreq)
                                                       state->count, err_list,
                                                       &pnn);
                if (ret2 != 0) {
-                       LOG("control DB_PUSH_CONFIRM failed for %s on node %u,"
-                           " ret=%d\n", recdb_name(state->recdb), pnn, ret2);
+                       D_ERR("control DB_PUSH_CONFIRM failed for db %s"
+                             " on node %u, ret=%d\n",
+                             recdb_name(state->recdb), pnn, ret2);
                } else {
-                       LOG("control DB_PUSH_CONFIRM failed for %s, ret=%d\n",
-                           recdb_name(state->recdb), ret);
+                       D_ERR("control DB_PUSH_CONFIRM failed for db %s,"
+                             " ret=%d\n",
+                             recdb_name(state->recdb), ret);
                }
                tevent_req_error(req, ret);
                return;
@@ -1041,9 +1044,9 @@ static void push_database_new_confirmed(struct tevent_req *subreq)
                }
 
                if (num_records != state->num_records) {
-                       LOG("Node %u received %d of %d records for %s\n",
-                           state->pnn_list[i], num_records,
-                           state->num_records, recdb_name(state->recdb));
+                       D_ERR("Node %u received %d of %d records for %s\n",
+                             state->pnn_list[i], num_records,
+                             state->num_records, recdb_name(state->recdb));
                        tevent_req_error(req, EPROTO);
                        return;
                }
@@ -1051,8 +1054,8 @@ static void push_database_new_confirmed(struct tevent_req *subreq)
 
        talloc_free(reply);
 
-       LOG("Pushed %d records for db %s\n",
-           state->num_records, recdb_name(state->recdb));
+       D_INFO("Pushed %d records for db %s\n",
+              state->num_records, recdb_name(state->recdb));
 
        tevent_req_done(req);
 }
@@ -1273,11 +1276,13 @@ static void collect_highseqnum_db_seqnum_done(struct tevent_req *subreq)
                                                       state->count, err_list,
                                                       &pnn);
                if (ret2 != 0) {
-                       LOG("control GET_DB_SEQNUM failed for %s on node %u,"
-                           " ret=%d\n", recdb_name(state->recdb), pnn, ret2);
+                       D_ERR("control GET_DB_SEQNUM failed for db %s"
+                             " on node %u, ret=%d\n",
+                             recdb_name(state->recdb), pnn, ret2);
                } else {
-                       LOG("control GET_DB_SEQNUM failed for %s, ret=%d\n",
-                           recdb_name(state->recdb), ret);
+                       D_ERR("control GET_DB_SEQNUM failed for db %s,"
+                             " ret=%d\n",
+                             recdb_name(state->recdb), ret);
                }
                tevent_req_error(req, ret);
                return;
@@ -1300,8 +1305,8 @@ static void collect_highseqnum_db_seqnum_done(struct tevent_req *subreq)
 
        talloc_free(reply);
 
-       LOG("Pull persistent db %s from node %d with seqnum 0x%"PRIx64"\n",
-           recdb_name(state->recdb), state->max_pnn, max_seqnum);
+       D_INFO("Pull persistent db %s from node %d with seqnum 0x%"PRIx64"\n",
+              recdb_name(state->recdb), state->max_pnn, max_seqnum);
 
        subreq = pull_database_send(state, state->ev, state->client,
                                    state->max_pnn,
@@ -1536,16 +1541,16 @@ static void recover_db_name_done(struct tevent_req *subreq)
        status = ctdb_client_control_recv(subreq, &ret, state, &reply);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("control GET_DBNAME failed for db=0x%x, ret=%d\n",
-                   state->db_id, ret);
+               D_ERR("control GET_DBNAME failed for db=0x%x, ret=%d\n",
+                     state->db_id, ret);
                tevent_req_error(req, ret);
                return;
        }
 
        ret = ctdb_reply_control_get_dbname(reply, state, &state->db_name);
        if (ret != 0) {
-               LOG("control GET_DBNAME failed for db=0x%x, ret=%d\n",
-                   state->db_id, ret);
+               D_ERR("control GET_DBNAME failed for db=0x%x, ret=%d\n",
+                     state->db_id, ret);
                tevent_req_error(req, EPROTO);
                return;
        }
@@ -1576,16 +1581,16 @@ static void recover_db_path_done(struct tevent_req *subreq)
        status = ctdb_client_control_recv(subreq, &ret, state, &reply);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("control GETDBPATH failed for db %s, ret=%d\n",
-                   state->db_name, ret);
+               D_ERR("control GETDBPATH failed for db %s, ret=%d\n",
+                     state->db_name, ret);
                tevent_req_error(req, ret);
                return;
        }
 
        ret = ctdb_reply_control_getdbpath(reply, state, &state->db_path);
        if (ret != 0) {
-               LOG("control GETDBPATH failed for db %s, ret=%d\n",
-                   state->db_name, ret);
+               D_ERR("control GETDBPATH failed for db %s, ret=%d\n",
+                     state->db_name, ret);
                tevent_req_error(req, EPROTO);
                return;
        }
@@ -1625,11 +1630,12 @@ static void recover_db_freeze_done(struct tevent_req *subreq)
                                                       state->count, err_list,
                                                       &pnn);
                if (ret2 != 0) {
-                       LOG("control FREEZE_DB failed for db %s on node %u,"
-                           " ret=%d\n", state->db_name, pnn, ret2);
+                       D_ERR("control FREEZE_DB failed for db %s"
+                             " on node %u, ret=%d\n",
+                             state->db_name, pnn, ret2);
                } else {
-                       LOG("control FREEZE_DB failed for db %s, ret=%d\n",
-                           state->db_name, ret);
+                       D_ERR("control FREEZE_DB failed for db %s, ret=%d\n",
+                             state->db_name, ret);
                }
                tevent_req_error(req, ret);
                return;
@@ -1667,11 +1673,12 @@ static void recover_db_transaction_started(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("control TRANSACTION_DB failed for db=%s on node %u,"
-                           " ret=%d\n", state->db_name, pnn, ret2);
+                       D_ERR("control TRANSACTION_DB failed for db=%s"
+                             " on node %u, ret=%d\n",
+                             state->db_name, pnn, ret2);
                } else {
-                       LOG("control TRANSACTION_DB failed for db=%s,"
-                           " ret=%d\n", state->db_name, ret);
+                       D_ERR("control TRANSACTION_DB failed for db=%s,"
+                             " ret=%d\n", state->db_name, ret);
                }
                tevent_req_error(req, ret);
                return;
@@ -1757,11 +1764,11 @@ static void recover_db_wipedb_done(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("control WIPEDB failed for db %s on node %u,"
-                           " ret=%d\n", state->db_name, pnn, ret2);
+                       D_ERR("control WIPEDB failed for db %s on node %u,"
+                             " ret=%d\n", state->db_name, pnn, ret2);
                } else {
-                       LOG("control WIPEDB failed for db %s, ret=%d\n",
-                           state->db_name, ret);
+                       D_ERR("control WIPEDB failed for db %s, ret=%d\n",
+                             state->db_name, ret);
                }
                tevent_req_error(req, ret);
                return;
@@ -1829,11 +1836,12 @@ static void recover_db_transaction_committed(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("control DB_TRANSACTION_COMMIT failed for db %s"
-                           " on node %u, ret=%d\n", state->db_name, pnn, ret2);
+                       D_ERR("control DB_TRANSACTION_COMMIT failed for db %s"
+                             " on node %u, ret=%d\n",
+                             state->db_name, pnn, ret2);
                } else {
-                       LOG("control DB_TRANSACTION_COMMIT failed for db %s,"
-                           " ret=%d\n", state->db_name, ret);
+                       D_ERR("control DB_TRANSACTION_COMMIT failed for db %s,"
+                             " ret=%d\n", state->db_name, ret);
                }
                tevent_req_error(req, ret);
                return;
@@ -1871,11 +1879,11 @@ static void recover_db_thaw_done(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("control DB_THAW failed for db %s on node %u,"
-                           " ret=%d\n", state->db_name, pnn, ret2);
+                       D_ERR("control DB_THAW failed for db %s on node %u,"
+                             " ret=%d\n", state->db_name, pnn, ret2);
                } else {
-                       LOG("control DB_THAW failed for db %s, ret=%d\n",
-                           state->db_name, ret);
+                       D_ERR("control DB_THAW failed for db %s, ret=%d\n",
+                             state->db_name, ret);
                }
                tevent_req_error(req, ret);
                return;
@@ -1979,7 +1987,7 @@ static struct tevent_req *db_recovery_send(TALLOC_CTX *mem_ctx,
                }
                tevent_req_set_callback(subreq, db_recovery_one_done,
                                        substate);
-               LOG("recover database 0x%08x\n", substate->db_id);
+               D_NOTICE("recover database 0x%08x\n", substate->db_id);
        }
 
        return req;
@@ -2014,8 +2022,8 @@ static void db_recovery_one_done(struct tevent_req *subreq)
                        goto failed;
                }
                tevent_req_set_callback(subreq, db_recovery_one_done, substate);
-               LOG("recover database 0x%08x, attempt %d\n", substate->db_id,
-                   substate->num_fails+1);
+               D_NOTICE("recover database 0x%08x, attempt %d\n",
+                        substate->db_id, substate->num_fails+1);
                return;
        }
 
@@ -2140,7 +2148,7 @@ static void recovery_tunables_done(struct tevent_req *subreq)
        status = ctdb_client_control_recv(subreq, &ret, state, &reply);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("control GET_ALL_TUNABLES failed, ret=%d\n", ret);
+               D_ERR("control GET_ALL_TUNABLES failed, ret=%d\n", ret);
                tevent_req_error(req, ret);
                return;
        }
@@ -2148,7 +2156,7 @@ static void recovery_tunables_done(struct tevent_req *subreq)
        ret = ctdb_reply_control_get_all_tunables(reply, state,
                                                  &state->tun_list);
        if (ret != 0) {
-               LOG("control GET_ALL_TUNABLES failed, ret=%d\n", ret);
+               D_ERR("control GET_ALL_TUNABLES failed, ret=%d\n", ret);
                tevent_req_error(req, EPROTO);
                return;
        }
@@ -2181,15 +2189,15 @@ static void recovery_nodemap_done(struct tevent_req *subreq)
        status = ctdb_client_control_recv(subreq, &ret, state, &reply);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("control GET_NODEMAP failed to node %u, ret=%d\n",
-                   state->destnode, ret);
+               D_ERR("control GET_NODEMAP failed to node %u, ret=%d\n",
+                     state->destnode, ret);
                tevent_req_error(req, ret);
                return;
        }
 
        ret = ctdb_reply_control_get_nodemap(reply, state, &state->nodemap);
        if (ret != 0) {
-               LOG("control GET_NODEMAP failed, ret=%d\n", ret);
+               D_ERR("control GET_NODEMAP failed, ret=%d\n", ret);
                tevent_req_error(req, ret);
                return;
        }
@@ -2231,15 +2239,15 @@ static void recovery_vnnmap_done(struct tevent_req *subreq)
        status = ctdb_client_control_recv(subreq, &ret, state, &reply);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("control GETVNNMAP failed to node %u, ret=%d\n",
-                   state->destnode, ret);
+               D_ERR("control GETVNNMAP failed to node %u, ret=%d\n",
+                     state->destnode, ret);
                tevent_req_error(req, ret);
                return;
        }
 
        ret = ctdb_reply_control_getvnnmap(reply, state, &state->vnnmap);
        if (ret != 0) {
-               LOG("control GETVNNMAP failed, ret=%d\n", ret);
+               D_ERR("control GETVNNMAP failed, ret=%d\n", ret);
                tevent_req_error(req, ret);
                return;
        }
@@ -2278,10 +2286,11 @@ static void recovery_capabilities_done(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("control GET_CAPABILITIES failed on node %u,"
-                           " ret=%d\n", pnn, ret2);
+                       D_ERR("control GET_CAPABILITIES failed on node %u,"
+                             " ret=%d\n", pnn, ret2);
                } else {
-                       LOG("control GET_CAPABILITIES failed, ret=%d\n", ret);
+                       D_ERR("control GET_CAPABILITIES failed, ret=%d\n",
+                             ret);
                }
                tevent_req_error(req, ret);
                return;
@@ -2301,7 +2310,8 @@ static void recovery_capabilities_done(struct tevent_req *subreq)
                ret = ctdb_reply_control_get_capabilities(reply[i],
                                                          &state->caps[pnn]);
                if (ret != 0) {
-                       LOG("control GET_CAPABILITIES failed on node %u\n", pnn);
+                       D_ERR("control GET_CAPABILITIES failed on node %u\n",
+                             pnn);
                        tevent_req_error(req, EPROTO);
                        return;
                }
@@ -2333,15 +2343,15 @@ static void recovery_dbmap_done(struct tevent_req *subreq)
        status = ctdb_client_control_recv(subreq, &ret, state, &reply);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("control GET_DBMAP failed to node %u, ret=%d\n",
-                   state->destnode, ret);
+               D_ERR("control GET_DBMAP failed to node %u, ret=%d\n",
+                     state->destnode, ret);
                tevent_req_error(req, ret);
                return;
        }
 
        ret = ctdb_reply_control_get_dbmap(reply, state, &state->dbmap);
        if (ret != 0) {
-               LOG("control GET_DBMAP failed, ret=%d\n", ret);
+               D_ERR("control GET_DBMAP failed, ret=%d\n", ret);
                tevent_req_error(req, ret);
                return;
        }
@@ -2380,17 +2390,17 @@ static void recovery_active_done(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("failed to set recovery mode to ACTIVE on node %u,"
-                           " ret=%d\n", pnn, ret2);
+                       D_ERR("failed to set recovery mode ACTIVE on node %u,"
+                             " ret=%d\n", pnn, ret2);
                } else {
-                       LOG("failed to set recovery mode to ACTIVE, ret=%d\n",
-                           ret);
+                       D_ERR("failed to set recovery mode ACTIVE, ret=%d\n",
+                             ret);
                }
                tevent_req_error(req, ret);
                return;
        }
 
-       LOG("set recovery mode to ACTIVE\n");
+       D_ERR("Set recovery mode to ACTIVE\n");
 
        /* Calculate new VNNMAP */
        count = 0;
@@ -2405,7 +2415,7 @@ static void recovery_active_done(struct tevent_req *subreq)
        }
 
        if (count == 0) {
-               LOG("no active lmasters found. Adding recmaster anyway\n");
+               D_WARNING("No active lmasters found. Adding recmaster anyway\n");
        }
 
        vnnmap = talloc_zero(state, struct ctdb_vnn_map);
@@ -2475,17 +2485,17 @@ static void recovery_start_recovery_done(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("failed to run start_recovery event on node %u,"
-                           " ret=%d\n", pnn, ret2);
+                       D_ERR("failed to run start_recovery event on node %u,"
+                             " ret=%d\n", pnn, ret2);
                } else {
-                       LOG("failed to run start_recovery event, ret=%d\n",
-                           ret);
+                       D_ERR("failed to run start_recovery event, ret=%d\n",
+                             ret);
                }
                tevent_req_error(req, ret);
                return;
        }
 
-       LOG("start_recovery event finished\n");
+       D_ERR("start_recovery event finished\n");
 
        ctdb_req_control_setvnnmap(&request, state->vnnmap);
        subreq = ctdb_client_control_multi_send(state, state->ev,
@@ -2519,16 +2529,16 @@ static void recovery_vnnmap_update_done(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("failed to update VNNMAP on node %u, ret=%d\n",
-                           pnn, ret2);
+                       D_ERR("failed to update VNNMAP on node %u, ret=%d\n",
+                             pnn, ret2);
                } else {
-                       LOG("failed to update VNNMAP, ret=%d\n", ret);
+                       D_ERR("failed to update VNNMAP, ret=%d\n", ret);
                }
                tevent_req_error(req, ret);
                return;
        }
 
-       LOG("updated VNNMAP\n");
+       D_NOTICE("updated VNNMAP\n");
 
        subreq = db_recovery_send(state, state->ev, state->client,
                                  state->dbmap, state->tun_list,
@@ -2554,7 +2564,7 @@ static void recovery_db_recovery_done(struct tevent_req *subreq)
        status = db_recovery_recv(subreq, &count);
        TALLOC_FREE(subreq);
 
-       LOG("%d of %d databases recovered\n", count, state->dbmap->num);
+       D_ERR("%d of %d databases recovered\n", count, state->dbmap->num);
 
        if (! status) {
                uint32_t max_pnn = CTDB_UNKNOWN_PNN, max_credits = 0;
@@ -2579,7 +2589,8 @@ static void recovery_db_recovery_done(struct tevent_req *subreq)
                if (max_credits >= NUM_RETRIES) {
                        struct ctdb_req_message message;
 
-                       LOG("Assigning banning credits to node %u\n", max_pnn);
+                       D_ERR("Assigning banning credits to node %u\n",
+                             max_pnn);
 
                        message.srvid = CTDB_SRVID_BANNING;
                        message.data.pnn = max_pnn;
@@ -2620,7 +2631,7 @@ static void recovery_failed_done(struct tevent_req *subreq)
        status = ctdb_client_message_recv(subreq, &ret);
        TALLOC_FREE(subreq);
        if (! status) {
-               LOG("failed to assign banning credits, ret=%d\n", ret);
+               D_ERR("failed to assign banning credits, ret=%d\n", ret);
        }
 
        tevent_req_error(req, EIO);
@@ -2648,17 +2659,17 @@ static void recovery_normal_done(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("failed to set recovery mode to NORMAL on node %u,"
-                           " ret=%d\n", pnn, ret2);
+                       D_ERR("failed to set recovery mode NORMAL on node %u,"
+                             " ret=%d\n", pnn, ret2);
                } else {
-                       LOG("failed to set recovery mode to NORMAL, ret=%d\n",
-                           ret);
+                       D_ERR("failed to set recovery mode NORMAL, ret=%d\n",
+                             ret);
                }
                tevent_req_error(req, ret);
                return;
        }
 
-       LOG("set recovery mode to NORMAL\n");
+       D_ERR("Set recovery mode to NORMAL\n");
 
        ctdb_req_control_end_recovery(&request);
        subreq = ctdb_client_control_multi_send(state, state->ev,
@@ -2692,16 +2703,16 @@ static void recovery_end_recovery_done(struct tevent_req *subreq)
                                                       state->count,
                                                       err_list, &pnn);
                if (ret2 != 0) {
-                       LOG("failed to run recovered event on node %u,"
-                           " ret=%d\n", pnn, ret2);
+                       D_ERR("failed to run recovered event on node %u,"
+                             " ret=%d\n", pnn, ret2);
                } else {
-                       LOG("failed to run recovered event, ret=%d\n", ret);
+                       D_ERR("failed to run recovered event, ret=%d\n", ret);
                }
                tevent_req_error(req, ret);
                return;
        }
 
-       LOG("recovered event finished\n");
+       D_ERR("recovered event finished\n");
 
        tevent_req_done(req);
 }
@@ -2755,31 +2766,31 @@ int main(int argc, char *argv[])
 
        ev = tevent_context_init(mem_ctx);
        if (ev == NULL) {
-               LOG("tevent_context_init() failed\n");
+               D_ERR("tevent_context_init() failed\n");
                goto failed;
        }
 
        ret = ctdb_client_init(mem_ctx, ev, sockpath, &client);
        if (ret != 0) {
-               LOG("ctdb_client_init() failed, ret=%d\n", ret);
+               D_ERR("ctdb_client_init() failed, ret=%d\n", ret);
                goto failed;
        }
 
        req = recovery_send(mem_ctx, ev, client, generation);
        if (req == NULL) {
-               LOG("database_recover_send() failed\n");
+               D_ERR("database_recover_send() failed\n");
                goto failed;
        }
 
        if (! tevent_req_poll(req, ev)) {
-               LOG("tevent_req_poll() failed\n");
+               D_ERR("tevent_req_poll() failed\n");
                goto failed;
        }
 
        recovery_recv(req, &ret);
        TALLOC_FREE(req);
        if (ret != 0) {
-               LOG("database recovery failed, ret=%d\n", ret);
+               D_ERR("database recovery failed, ret=%d\n", ret);
                goto failed;
        }