Skip to content

Commit eb6ccef

Browse files
davidkellythejcfactor
authored andcommitted
Update to latest cxx client
Minor change in the name of the logging macros in cxx client (to avoid naming collisions), needed to update those calls. Pulls in latest changes, including some performance improvements. Change-Id: Ib059c44daf441c04e082608e95bd52d2db7d6f20 Reviewed-on: https://review.couchbase.org/c/couchbase-python-client/+/185747 Tested-by: Build Bot <[email protected]> Reviewed-by: Jared Casey <[email protected]>
1 parent e15e4fd commit eb6ccef

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

src/client.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ json_encode(PyObject* obj)
195195
res = std::string(PyUnicode_AsUTF8(encoded));
196196
}
197197
Py_XDECREF(encoded);
198-
// LOG_DEBUG("encoded document: {}", res);
198+
// CB_LOG_DEBUG("encoded document: {}", res);
199199
return res;
200200
}
201201

src/connection.cxx

+6-6
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ dealloc_conn(PyObject* obj)
8585
}
8686
}
8787
}
88-
LOG_DEBUG("{}: dealloc_conn completed", "PYCBC");
88+
CB_LOG_DEBUG("{}: dealloc_conn completed", "PYCBC");
8989
delete conn;
9090
}
9191

@@ -137,7 +137,7 @@ bucket_op_callback(std::error_code ec,
137137
Py_XDECREF(pyObj_callback);
138138
Py_XDECREF(pyObj_errback);
139139
}
140-
LOG_DEBUG("{}: open/close bucket callback completed", "PYCBC");
140+
CB_LOG_DEBUG("{}: open/close bucket callback completed", "PYCBC");
141141
PyGILState_Release(state);
142142
}
143143

@@ -163,7 +163,7 @@ close_connection_callback(PyObject* pyObj_conn,
163163

164164
if (pyObj_func != nullptr) {
165165
pyObj_callback_res = PyObject_CallObject(pyObj_func, pyObj_args);
166-
LOG_DEBUG("{}: return from close conn callback.", "PYCBC");
166+
CB_LOG_DEBUG("{}: return from close conn callback.", "PYCBC");
167167
if (pyObj_callback_res) {
168168
Py_DECREF(pyObj_callback_res);
169169
} else {
@@ -173,7 +173,7 @@ close_connection_callback(PyObject* pyObj_conn,
173173
Py_XDECREF(pyObj_callback);
174174
Py_XDECREF(pyObj_errback);
175175
}
176-
LOG_DEBUG("{}: close conn callback completed", "PYCBC");
176+
CB_LOG_DEBUG("{}: close conn callback completed", "PYCBC");
177177
auto conn = reinterpret_cast<connection*>(PyCapsule_GetPointer(pyObj_conn, "conn_"));
178178
conn->io_.stop();
179179
// the pyObj_conn was incref'd before being passed into this callback, decref it here
@@ -226,7 +226,7 @@ create_connection_callback(PyObject* pyObj_conn,
226226
Py_XDECREF(pyObj_errback);
227227
}
228228
Py_DECREF(pyObj_conn);
229-
LOG_DEBUG("{}: create conn callback completed", "PYCBC");
229+
CB_LOG_DEBUG("{}: create conn callback completed", "PYCBC");
230230
PyGILState_Release(state);
231231
}
232232

@@ -1184,7 +1184,7 @@ handle_close_connection([[maybe_unused]] PyObject* self, PyObject* args, PyObjec
11841184
if (callback_count == 0) {
11851185
close_connection_callback(pyObj_conn, pyObj_callback, pyObj_errback, barrier);
11861186
} else {
1187-
LOG_DEBUG("close callback called {} times already!", callback_count);
1187+
CB_LOG_DEBUG("close callback called {} times already!", callback_count);
11881188
callback_count++;
11891189
}
11901190
});

src/exceptions.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ exception_base_dealloc(exception_base* self)
7575
Py_DECREF(self->exc_info);
7676
}
7777
Py_TYPE(self)->tp_free((PyObject*)self);
78-
LOG_DEBUG("{}: exception_base_dealloc completed", "PYCBC");
78+
CB_LOG_DEBUG("{}: exception_base_dealloc completed", "PYCBC");
7979
}
8080

8181
static PyObject*

src/kv_ops.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ create_result_from_mutation_operation_response(const char* key,
733733
Py_XDECREF(pyObj_callback);
734734
Py_XDECREF(pyObj_errback);
735735
}
736-
// LOG_DEBUG("{}: create mutation callback completed", "PYCBC");
736+
// CB_CB_CB_LOG_DEBUG("{}: create mutation callback completed", "PYCBC");
737737
PyGILState_Release(state);
738738
}
739739

src/metrics.hxx

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class value_recorder : public metrics::value_recorder
3535
// A value_recorder is only created from meter::get_value_recorder, which is responsible for obtaining the GIL
3636
Py_INCREF(pyObj_recorder_);
3737
pyObj_record_value_ = PyObject_GetAttrString(pyObj_recorder_, "record_value");
38-
LOG_DEBUG("{}: created value_recorder", "PYCBC");
38+
CB_LOG_DEBUG("{}: created value_recorder", "PYCBC");
3939
}
4040

4141
~value_recorder() override
@@ -44,7 +44,7 @@ class value_recorder : public metrics::value_recorder
4444
Py_DECREF(pyObj_recorder_);
4545
Py_DECREF(pyObj_record_value_);
4646
PyGILState_Release(state);
47-
LOG_DEBUG("{}: destroyed value_recorder", "PYCBC");
47+
CB_LOG_DEBUG("{}: destroyed value_recorder", "PYCBC");
4848
}
4949

5050
void record_value(std::int64_t value) override

src/result.cxx

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ result_dealloc([[maybe_unused]] result* self)
8989
PyDict_Clear(self->dict);
9090
Py_DECREF(self->dict);
9191
}
92-
// LOG_DEBUG("pycbc - dealloc result: result->refcnt: {}, result->dict->refcnt: {}", Py_REFCNT(self), Py_REFCNT(self->dict));
92+
// CB_LOG_DEBUG("pycbc - dealloc result: result->refcnt: {}, result->dict->refcnt: {}", Py_REFCNT(self), Py_REFCNT(self->dict));
9393
Py_TYPE(self)->tp_free((PyObject*)self);
9494
}
9595

@@ -150,7 +150,7 @@ static void
150150
mutation_token_dealloc([[maybe_unused]] mutation_token* self)
151151
{
152152
delete self->token;
153-
// LOG_DEBUG("pycbc - dealloc mutation_token: token->refcnt: {}", Py_REFCNT(self));
153+
// CB_LOG_DEBUG("pycbc - dealloc mutation_token: token->refcnt: {}", Py_REFCNT(self));
154154
Py_TYPE(self)->tp_free((PyObject*)self);
155155
}
156156

@@ -239,7 +239,7 @@ PyTypeObject streamed_result_type = { PyObject_HEAD_INIT(NULL) 0 };
239239
static void
240240
streamed_result_dealloc([[maybe_unused]] streamed_result* self)
241241
{
242-
// LOG_DEBUG("pycbc - dealloc streamed_result: result->refcnt: {}", Py_REFCNT(self));
242+
// CB_LOG_DEBUG("pycbc - dealloc streamed_result: result->refcnt: {}", Py_REFCNT(self));
243243
Py_TYPE(self)->tp_free((PyObject*)self);
244244
}
245245

src/transactions/transactions.cxx

+11-11
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ pycbc_txns::dealloc_transactions(PyObject* obj)
5555
auto txns = reinterpret_cast<pycbc_txns::transactions*>(PyCapsule_GetPointer(obj, "txns_"));
5656
txns->txns->close();
5757
delete txns->txns;
58-
LOG_DEBUG("dealloc transactions");
58+
CB_LOG_DEBUG("dealloc transactions");
5959
}
6060

6161
void
6262
pycbc_txns::dealloc_attempt_context(PyObject* obj)
6363
{
6464
auto ctx = reinterpret_cast<pycbc_txns::attempt_context*>(PyCapsule_GetPointer(obj, "ctx_"));
6565
delete ctx;
66-
LOG_DEBUG("dealloc attempt_context");
66+
CB_LOG_DEBUG("dealloc attempt_context");
6767
}
6868

6969
/* pycbc_txns::transaction_config type methods */
@@ -73,7 +73,7 @@ pycbc_txns::transaction_config__dealloc__(pycbc_txns::transaction_config* cfg)
7373
{
7474
delete cfg->cfg;
7575
Py_TYPE(cfg)->tp_free((PyObject*)cfg);
76-
LOG_DEBUG("dealloc transaction_config");
76+
CB_LOG_DEBUG("dealloc transaction_config");
7777
}
7878

7979
PyObject*
@@ -203,7 +203,7 @@ pycbc_txns::transaction_options__dealloc__(pycbc_txns::transaction_options* opts
203203
{
204204
delete opts->opts;
205205
Py_TYPE(opts)->tp_free((PyObject*)opts);
206-
LOG_DEBUG("dealloc transaction_options");
206+
CB_LOG_DEBUG("dealloc transaction_options");
207207
}
208208

209209
PyObject*
@@ -279,7 +279,7 @@ pycbc_txns::transaction_options__new__(PyTypeObject* type, PyObject* args, PyObj
279279
auto self = reinterpret_cast<pycbc_txns::transaction_options*>(type->tp_alloc(type, 0));
280280

281281
self->opts = new tx::transaction_options();
282-
LOG_DEBUG("transaction_options__new__ called");
282+
CB_LOG_DEBUG("transaction_options__new__ called");
283283
if (!PyArg_ParseTupleAndKeywords(args,
284284
kwargs,
285285
kw_format,
@@ -338,7 +338,7 @@ pycbc_txns::transaction_query_options__dealloc__(pycbc_txns::transaction_query_o
338338
{
339339
delete opts->opts;
340340
Py_TYPE(opts)->tp_free((PyObject*)opts);
341-
LOG_DEBUG("dealloc transaction_query_options");
341+
CB_LOG_DEBUG("dealloc transaction_query_options");
342342
}
343343

344344
PyObject*
@@ -517,7 +517,7 @@ pycbc_txns::transaction_get_result__dealloc__(pycbc_txns::transaction_get_result
517517
{
518518
delete result->res;
519519
Py_TYPE(result)->tp_free((PyObject*)result);
520-
LOG_DEBUG("dealloc transaction_get_result");
520+
CB_LOG_DEBUG("dealloc transaction_get_result");
521521
}
522522

523523
PyObject*
@@ -750,7 +750,7 @@ convert_to_python_exc_type(std::exception_ptr err, bool set_exception = false)
750750
} catch (const tx_core::query_parsing_failure& e) {
751751
pyObj_exc_type = pyObj_query_parsing_failure;
752752
message = e.what();
753-
} catch (const tx_core::query_exception& e) {
753+
} catch (const tx_core::op_exception& e) {
754754
pyObj_exc_type = pyObj_couchbase_error;
755755
message = e.what();
756756
} catch (const std::exception& e) {
@@ -992,7 +992,7 @@ pycbc_txns::transaction_op([[maybe_unused]] PyObject* self, PyObject* args, PyOb
992992
}
993993
auto size = py_ssize_t_to_size_t(nbuf);
994994
value = couchbase::core::utils::json::parse(reinterpret_cast<const char*>(buf), size);
995-
LOG_DEBUG("value is {}", buf);
995+
CB_LOG_DEBUG("value is {}", buf);
996996
}
997997
if (nullptr == pyObj_ctx) {
998998
PyErr_SetString(PyExc_ValueError, "no attempt_context passed in");
@@ -1071,7 +1071,7 @@ pycbc_txns::transaction_op([[maybe_unused]] PyObject* self, PyObject* args, PyOb
10711071
}
10721072
default:
10731073
// return error!
1074-
LOG_DEBUG("unknown op {}", op_type);
1074+
CB_LOG_DEBUG("unknown op {}", op_type);
10751075
PyErr_SetString(PyExc_ValueError, "unknown txn operation");
10761076
}
10771077
if (nullptr == pyObj_callback || nullptr == pyObj_errback) {
@@ -1224,7 +1224,7 @@ pycbc_txns::run_transactions([[maybe_unused]] PyObject* self, PyObject* args, Py
12241224
else
12251225
{
12261226
auto expiry = opts->expiration_time();
1227-
LOG_DEBUG("calling transactions.run with expiry {}ms", expiry.has_value() ? expiry->count() : 0);
1227+
CB_LOG_DEBUG("calling transactions.run with expiry {}ms", expiry.has_value() ? expiry->count() : 0);
12281228
// @TODO: PYCBC-1425, is this the right approach?
12291229
txns->txns->run(*opts, logic, std::forward<pycbc_txns::pycbc_txn_complete_callback>(cb));
12301230
}

0 commit comments

Comments
 (0)