diff options
| author | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2016-10-26 16:16:18 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2016-10-26 16:16:18 -0400 |
| commit | 56b0cf6b54bd666a840bc35b1c5f8099906be320 (patch) | |
| tree | 08185482c443f759060aa15c822a217ed62bd956 | |
| parent | f7ab19d4dfa4a9a8b4f5c098fe0a816f7ed4c40a (diff) | |
| download | pyisda-56b0cf6b54bd666a840bc35b1c5f8099906be320.tar.gz | |
enable logging facility
| -rw-r--r-- | pyisda/logging.pxd | 10 | ||||
| -rw-r--r-- | pyisda/logging.pyx | 20 |
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 |
