Closed jkleint closed 8 years ago
I took the logging thing one step further and allow users to have a filename or a buffer as the logging
value instead of True
/False
.
Added two optional parameters to __init__()
for auto-logging: logger as the log type (either "stream" for stdout or "file") and logger_file as log file path (if logger == "file")
Example:
ibConn = ezIBpy(logger="stream") # also accepts "stdout"
or
ibConn = ezIBpy(logger="file", logger_file="path/to/file.log") # also accepts "filename"
Hope you'll like it :)
Version 1.12.27 released!
Hey Ran, thanks, glad you liked it. I was actually thinking it might be easier to just let the builtin Python logger do its thing, since it's already programmatically configurable to set the level and the stream, even from other modules, without you having to write or maintain any code! All you have to do is initialize the logger with a name, and then people can log the normal Python way that most all other Python software does.
I'm happy to whip up the patch for this, just let me know.
https://docs.python.org/2/howto/logging-cookbook.html#logging-cookbook
That's actually more elegant than my solution. I'd love it if you could write the patch 👍
Thanks!
handleErrorEvents()
was callingibCallback()
with amsg
consisting of just the integer error code. The other callbacks all expect a message object. Passing the full object allows clients to handle messages uniformly and extract the error message text.Added
logging=False
kwarg toezIBpy.__init__()
to make logging possible.It seems like maybe
izIBpy()
was avoiding kwargs by design, so if another method is preferred (aconfigure()
method or something) that's fine.Also, it's not clear what the
ezIBpy.log()
method buys: it would be less typing to just uselogging.info()
and friends directly, and you would only have to enable logging in one place, using the standard Python method. Seems simpler, but I refrained from refactoring.