![]() |
Avoid third party functions to wrote my python code into system debug-log? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Avoid third party functions to wrote my python code into system debug-log? (/thread-36887.html) |
Avoid third party functions to wrote my python code into system debug-log? - mark - Apr-08-2022 I already asked this on stackoverflow, i will here as well. I'm not sure how exactly to explain this question because my english is no so god. But i will try with the sample source code. I am on some open-embedded system where system debug-log can be enabled or disabled. If is enabled all events from boot to reboot are written into debug log in /home/root/logs/ folder. So any code which i wrote in my python app is written to this debug log. How to avoid this? Let me explain with some piece of code. startStream is my code: def startStream(myUrl): from SomeFolder.SomeApp.SomeFile import PlayStream PlayStream(myUrl)PlayStream isn't my code. it's somewhere on the system: def PlayStream(url): print(url) session.PlayService(url)So as you can see, PlayStream function will write down my url into debug log, but i don't want this. I don't want to people see my links (in this case). Let me explain that SomeFolder.SomeApp.SomeFile import PlayStream is a imaginary import and function name and can be a lot of similar function anywhere across the system. How to avoid that third party functions/methods from python or from other languages wrote my python stuff into system debug log? RE: Avoid third party functions to wrote my python code into system debug-log? - mark - Apr-09-2022 If anything means for you guys: I have already tried to redirect print which i want to hide from stdout to file or string buffer, but it seems nothing works. Solution form here doesn't work. https://stackoverflow.com/a/1218951/9157441 For example: from cStringIO import StringIO # Python3 use: from io import StringIO import sys def startStream(myUrl): old_stdout = sys.stdout sys.stdout = mystdout = StringIO() from SomeFolder.SomeApp.SomeFile import PlayStream PlayStream(myUrl)An again in system debug-log:
RE: Avoid third party functions to wrote my python code into system debug-log? - mark - Apr-09-2022 For example if i call servicemp3 to play my url, this the output from servicemp3.cpp in debug-log: The same thing is for exteplayer3 or any player.The point is how to avoid prints from third party apps? I am so sorry for three posts in a row, but I’m trying to portray my problem the best I can. RE: Avoid third party functions to wrote my python code into system debug-log? - Gribouillis - Apr-09-2022 If Python code is logging things with the logging module, you could try to disable it with import logging logging.disable(logging.CRITICAL) RE: Avoid third party functions to wrote my python code into system debug-log? - mark - Apr-09-2022 it doesn't work. Everything is as before. RE: Avoid third party functions to wrote my python code into system debug-log? - ndc85430 - Apr-09-2022 It would probably help if you showed real code - looks like there's some C++ library in there ( servicemp3.cpp ), so perhaps the logging in there needs configuring if, that's even possible.
RE: Avoid third party functions to wrote my python code into system debug-log? - mark - Apr-09-2022 Guys, thank you for your interest. Sadly i can't change anything in C++ code. i'll try with some 'live' code, but it's complicated and i hope you will understand, because some stuff i do not know explain how works. For example here is servicemp3.cpp where is 'eServiceReference'. servicemp3.cpp is compiled to enigma binary, from which i import 'eServiceReference' from enigma import eServiceReference def play(self): url = "http://someurl.com:80/blah.mp4" service = eServiceReference(4097, 0, url) # here's playing start: self.session.nav.playService(service) # i am not sure from which above line come, i think from Navigation.py, but it's not need to be imported to work # https://github.com/openatv/enigma2/blob/7.0/lib/python/Navigation.pybtw, 4097 = gstreamer, 5002 = exteplayer3, etc... So, after i run this code, debug-log will write: I also tried to disable debug (only to show warnning), for 'eServiceReference' after import. Nothing, again the same output.import logging logging.getLogger("eServiceReference").setLevel(logging.WARNING)I also tried to disable debug for 'enigma'. You can guess, nothing of course, again the same output. import logging logging.getLogger("enigma").setLevel(logging.WARNING)So, what else i can try? May i disable debug for function (def play)? This drives me nuts, because nothing happened whatever i try. RE: Avoid third party functions to wrote my python code into system debug-log? - mark - Apr-09-2022 Something is wrong on my side. I do not know why. Pls check this out. Let's try to simplify stuff. main.py from . dialog import myDialog import logging logging.getLogger("dialog").setLevel(logging.WARNING) myDialog()dialog.py def myDialog(): print("00000000000000000000000000000000000000000000000000000000000001212121211121")in debug-log: According to this code print can't be written to debug?So, what i missing here? RE: Avoid third party functions to wrote my python code into system debug-log? - Gribouillis - Apr-09-2022 Look at the debug log. Clearly it depends on how the python interpreter was called to execute the code. There is no mention of the twisted module in the code, but it appears in the debug log.
RE: Avoid third party functions to wrote my python code into system debug-log? - mark - Apr-09-2022 Yes, that is totally strange. |