-
Notifications
You must be signed in to change notification settings - Fork 111
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
Instance: add a set_logger method #273
base: master
Are you sure you want to change the base?
Conversation
Citing from Python 3.12 release: "A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning (...) In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning." https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes
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.
Looks great. Please see if you can address the comments.
Add a way to load the local standard C library. This could be used to load some C standard functions, like *printf ones. This should work on Linux, Windows and macOS/Darwin environments.
Adds a way to link libVLC log system to a python logging.Logger object. The logger and log callback is attached to the libVLC Instance object to avoid the python garbage collector to destroy them too soon. NOTE: as libVLC log messages are based on a printf + va_list format, we need to use the standard C `vsnprintf` function with a max fixed size output.
Adds a functional test for the Instance.set_logger method. This will also test the log_get_context, as this is part of the logger output.
This can be useful if some logger is set and you want to get access to it afterwards.
I did not forget about this one, but I knew I had another (big) one pending for which I should also dedicated some time. Now that #275 is merged, I can merge this one, but it needs some porting to the new code - no real conflict, just moving things around I think. If you have some time to look at it, great. Else, I will do it some day. |
This MR adds a way to link libVLC log system to a python logging.Logger object.
A new
set_logger
method is added to the Instance class to link a logging.Logger to the libvlc_log_set callback setup.The additional info from the log context (vlc module name, file, line, etc) are attached as extra info.
The log context test is modified to check the set_logger behavior (as the context info is included in the logger).
Tested on Linux and Windows, should work on macOS.