From 292f0b8b1a580b7f442bb645610c58d632b07cbc Mon Sep 17 00:00:00 2001 From: Amen Belayneh Date: Tue, 8 Sep 2020 16:16:11 +0800 Subject: [PATCH 1/2] wrap ure logger --- opencog/cython/opencog/logger.pyx | 7 +++++++ opencog/cython/opencog/ure.pxd | 5 +++++ opencog/cython/opencog/ure.pyx | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 opencog/cython/opencog/logger.pyx diff --git a/opencog/cython/opencog/logger.pyx b/opencog/cython/opencog/logger.pyx new file mode 100644 index 0000000000..876a9e6bb0 --- /dev/null +++ b/opencog/cython/opencog/logger.pyx @@ -0,0 +1,7 @@ +from ure cimport ure_logger as c_ure_logger +from opencog.logger cimport wrap_clogger, cLogger + +def ure_logger(): + cdef cLogger cl = c_ure_logger() + z= wrap_clogger(&cl) + return z diff --git a/opencog/cython/opencog/ure.pxd b/opencog/cython/opencog/ure.pxd index fdf8861534..85e9361321 100644 --- a/opencog/cython/opencog/ure.pxd +++ b/opencog/cython/opencog/ure.pxd @@ -1,6 +1,7 @@ from libcpp.set cimport set from libcpp.vector cimport vector from opencog.atomspace cimport cHandle, cAtomSpace +from opencog.logger cimport cLogger cdef extern from "opencog/ure/forwardchainer/ForwardChainer.h" namespace "opencog": @@ -69,3 +70,7 @@ cdef extern from "opencog/ure/backwardchainer/BackwardChainer.h" namespace "open void do_chain() except + cHandle get_results() const + + +cdef extern from "opencog/ure/URELogger.h" namespace "opencog": + cdef cLogger& ure_logger() diff --git a/opencog/cython/opencog/ure.pyx b/opencog/cython/opencog/ure.pyx index 4095904948..5af6b556f4 100644 --- a/opencog/cython/opencog/ure.pyx +++ b/opencog/cython/opencog/ure.pyx @@ -6,4 +6,5 @@ # things work or not include "forwardchainer.pyx" -include "backwardchainer.pyx" \ No newline at end of file +include "backwardchainer.pyx" +include "logger.pyx" From 4083d2354302ba985093d2cdfd54e50176862a07 Mon Sep 17 00:00:00 2001 From: Nil Geisweiller Date: Tue, 8 Sep 2020 15:46:35 +0300 Subject: [PATCH 2/2] Pass c_ure_logger() output directly by reference --- opencog/cython/opencog/logger.pyx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/opencog/cython/opencog/logger.pyx b/opencog/cython/opencog/logger.pyx index 876a9e6bb0..af9909562a 100644 --- a/opencog/cython/opencog/logger.pyx +++ b/opencog/cython/opencog/logger.pyx @@ -2,6 +2,5 @@ from ure cimport ure_logger as c_ure_logger from opencog.logger cimport wrap_clogger, cLogger def ure_logger(): - cdef cLogger cl = c_ure_logger() - z= wrap_clogger(&cl) + z = wrap_clogger(&c_ure_logger()) return z