"print" statement inside Enigma2 p...
microboi37 20 Feb 2019
I've seen a lot of print statements in various Enigma2 plugins and I wonder where the print output is printed since Enigma2 plugins are executed inside Enigma2 and not inside the console. I have tried to check the dmesg output but it seems dmesg doesn't capture python print outputs.
def function(self): try: x = y except Exception as ex: print ex print 'ERROR'
Where does print ex print?
Trial 20 Feb 2019
Hi,
in most images you can active debug log and there you should find the print output. If there is no debug log you must start enigma2 in telnet to see the prints.
ciao
microboi37 20 Feb 2019
Ok, super difficult to debug this way since
ENIGMA_DEBUG_LVL=4 enigma2
logs too much things. I'll key debugging through log file inside script. Thank you.
mfaraj57 20 Feb 2019
print statement is bad in enigma and annoying you can use your own log system is much better as following
def log(label_name = '', data = ''): try: data = str(data) fp = open('/tmp/mylog', 'a') fp.write('\n' + str(label_name) + ': ' + data) fp.close() except: pass log("error",error)
WanWizard 20 Feb 2019
That depends on the purpose.
Print statements provide debug output, and are included in for example crash logs. The are needed to figure out why something crashed.
If you feel the need to write (like in this example) exception logging to a file, you need to become a better programmer. Exceptions are exactly that, they should ONLY occur when something unexpected happens, and not because (again like in this example) you couldn't be bothered to properly validate your data before using it.
Also note that stdout and stderr are captured and processed depending on the debug level set. Writing to your own file not only bypasses this mechanism, but also causes your log not to show up if this mechanism is overridden centrally, for example to send log data elsewhere.
Note that debug ouput != application logging.
Logging application processing, for example autotimer timer processing details, should be written to an application specific log file, it has no place in debug output, and only floods the output with irrelevant data.
Edited by WanWizard, 20 February 2019 - 13:55.
betacentauri 20 Feb 2019
Ok, super difficult to debug this way since
ENIGMA_DEBUG_LVL=4 enigma2logs too much things. I'll key debugging through log file inside script. Thank you.
I always use special keywords as prefix for debugging. Something like
print “AAA start”
...
print “AAA result”, r
...
print “AAA end”
Yes, not very nice. But you find your debug messages quite easy.
WanWizard 20 Feb 2019
You'll see in the code a lot of messages starts with "[name]" for that same reason.
MiLo 23 Feb 2019
With that in place, it would be logic to have all "log" calls go to E2's logging, and "print" statements to the console (thus, all current "print" statements should be replaced with "log" or removed entirely)