I'm using embedded python interpreter in my iOS app. I'm able to see print
output in Xcode console, but i'm unable to see any logging.info()
or logging.debug()
output. How can i enable it?
My test python code:
import logging
import sys
# try to add logging output to stdout
logging.basicConfig()
log = logging.getLogger()
log.addHandler(logging.StreamHandler())
log.addHandler(logging.StreamHandler(sys.stdout))
# for calling from outside
def main__(args):
print("main__()") # can see output
print type(args)
print len(args)
for eachArg in args:
# print('#: %s' % eachArg) # can see output
logging.info(eachArg) # can NOT see output
Output is:
main__()
<type 'list'>
281
I think the stuff is in debug level. This code works for me:
import logging
import sys
log = logging.getLogger()
log.setLevel(logging.DEBUG)
stream = logging.StreamHandler(sys.stdout)
stream.setLevel(logging.DEBUG)
log.addHandler(stream)
# for calling from outside
def main__(args):
print("main__()") # can see output
print type(args)
print len(args)
for eachArg in args:
logging.info(eachArg)
output:
>>> main__('test')
main__()
<type 'str'>
4
t
e
s
t
>>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With