New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-15361: Enable logging to Python streams. #33
Conversation
This is not just for logging only - it takes anything written to a file descriptor and sends it somewhere? Can't we implement special appender for log4cxx to write directly to Python object? |
In a notebook environment, nothing else should be writing to the file descriptor. I thought this would be a quick, Python-only way to start getting the desired functionality. Writing a log4cxx appender seemed more difficult. |
Implementing log4cxx appender should not be hard, the only non-trivial question is how to configure log4cxx, but that can be done through some special utility method. Anyways, I'm OK with this initial implementation. Maybe if we can provide a more abstract API for enabling redirection then we can re-implement it later in a different way without need to change user code, e.g:
|
@@ -37,3 +41,62 @@ def traceSetAt(name, number): | |||
for i in range(6): | |||
level = Log.INFO if i > number else Log.DEBUG | |||
Log.getLogger('TRACE%d.%s' % (i, name)).setLevel(level) | |||
|
|||
|
|||
class LogRedirect: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like singletons but this should not be allowed to be instantiated more than once.
3ff6c09
to
3f3249e
Compare
dd80801
to
26d876a
Compare
This allows log output to go to Jupyter notebook cells.