Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
mgr: redirect python stdout,stderr to ceph log #14189
referenced this pull request
Mar 28, 2017
OK, this works for me (the errors that weren't being logged that I mentioned in #14126 do get logged with this patch applied), and actually means we could drop the
now the output with "-f" looks like
// i added a
(only just saw this one)
For the exception handling, I think it's cleaner to keep the explicit code that generates a string and sends it to the log, rather than relying on plumbing python's stderr into our log at level 0.
The problem with sending stderr to level 0 is that if you instantiate a python StreamHandler log handler, that goes to stderr by default. So any module that happens to spin one of those up by default (like a web server that thinks its logging to the console) will end up generating level 0 messages in the ceph log.
So I guess I would suggest keeping the explicit exception handler (sending its strings to dout(0)), and maybe have the python stderr handler send its strings to dout(4) or something like that, so that if someone wants to see their python module stderr they can, but we don't send it to our log level 0 by default.
LGTM, I'm guessing that the py_logger member is not doing any harm because it's a global thing getting town down in finalize anyway. @dmick's changes should sit neatly on top of this and convert some of those PyErr_Print calls into explicit logging of exceptions, so that the stderr/stdout handling is just a fallback for any python code that wants to write there.