summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pyisda/logging.pxd10
-rw-r--r--pyisda/logging.pyx20
2 files changed, 30 insertions, 0 deletions
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