From 56b0cf6b54bd666a840bc35b1c5f8099906be320 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Wed, 26 Oct 2016 16:16:18 -0400 Subject: enable logging facility --- pyisda/logging.pxd | 10 ++++++++++ pyisda/logging.pyx | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 pyisda/logging.pxd create mode 100644 pyisda/logging.pyx diff --git a/pyisda/logging.pxd b/pyisda/logging.pxd new file mode 100644 index 0000000..efe3b2f --- /dev/null +++ b/pyisda/logging.pxd @@ -0,0 +1,10 @@ +cdef extern from "isda/cerror.h": + ctypedef int TBoolean + void JpmcdsErrMsgOn() + void JpmcdsErrMsgOff() + void JpmcdsErrLogWrite(char* message) + int JpmcdsErrMsgFileName( + char *fileName, # (I) File name to use. + TBoolean append # (I) Append flag. + ) + int JpmcdsErrMsgFlush() diff --git a/pyisda/logging.pyx b/pyisda/logging.pyx new file mode 100644 index 0000000..5aa5282 --- /dev/null +++ b/pyisda/logging.pyx @@ -0,0 +1,20 @@ +def enable_logging(): + JpmcdsErrMsgOn() + +def disable_logging(): + JpmcdsErrMsgOff() + +def set_logging_file(str file_name, TBoolean append = True): + filename_bytes = file_name.encode('utf-8') + cdef char* c_string = filename_bytes + if JpmcdsErrMsgFileName(c_string, append) !=0: + raise + +def log_message(str msg): + msg_bytes = msg.encode('utf-8') + cdef char* c_msg = msg_bytes + JpmcdsErrLogWrite(c_msg) + +def flush(): + if JpmcdsErrMsgFlush() !=0: + raise -- cgit v1.2.3-70-g09d2