Springen naar inhoud


Foto

"print" statement inside Enigma2 plugins


  • Please log in to reply
Er zijn 8 reacties in dit onderwerp

#1 microboi37

  • Senior Member
  • 74 berichten

0
Neutral

Geplaatst op 20 februari 2019 - 08:22

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?



Re: "print" statement inside Enigma2 plugins #2 Trial

  • Senior Member
  • 1127 berichten

+34
Good

Geplaatst op 20 februari 2019 - 08:52

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



Re: "print" statement inside Enigma2 plugins #3 microboi37

  • Senior Member
  • 74 berichten

0
Neutral

Geplaatst op 20 februari 2019 - 09:13

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.



Re: "print" statement inside Enigma2 plugins #4 mfaraj57

  • Senior Member
  • 1605 berichten

+286
Excellent

Geplaatst op 20 februari 2019 - 12:08

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)


Re: "print" statement inside Enigma2 plugins #5 WanWizard

  • PLi® Core member
  • 68303 berichten

+1718
Excellent

Geplaatst op 20 februari 2019 - 13:47

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. 


Veranderd door WanWizard, 20 februari 2019 - 13:55

Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Pro (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: "print" statement inside Enigma2 plugins #6 betacentauri

  • PLi® Core member
  • 7185 berichten

+323
Excellent

Geplaatst op 20 februari 2019 - 16:53

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.

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.
Xtrend ET-9200, ET-8000, ET-10000, OpenPliPC on Ubuntu 12.04

Re: "print" statement inside Enigma2 plugins #7 WanWizard

  • PLi® Core member
  • 68303 berichten

+1718
Excellent

Geplaatst op 20 februari 2019 - 17:25

You'll see in the code a lot of messages starts with "[name]" for that same reason.


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Pro (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: "print" statement inside Enigma2 plugins #8 MiLo

  • PLi® Core member
  • 14042 berichten

+298
Excellent

Geplaatst op 23 februari 2019 - 15:47

I think Python already has a nice logging framework that could be plugged into E2, so that it also participates in the "log level" options.

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)
Real musicians never die - they just decompose

Re: "print" statement inside Enigma2 plugins #9 WanWizard

  • PLi® Core member
  • 68303 berichten

+1718
Excellent

Geplaatst op 23 februari 2019 - 17:08

+1.


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Pro (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.



1 gebruiker(s) lezen dit onderwerp

0 leden, 1 bezoekers, 0 anonieme gebruikers