Re: PyQt5/Android: print/log messages
Rodrigo Oliveira <[email protected]> Mon, 27 Apr 2020 11:51:58 -0300
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Message-ID | <CAHhvZ=TrH8Ax5HV2ie1HixYnrwjoGZo+_XEPj4jRGMZOYiU+aQ@mail.gmail.com> |
awesome, this works, thanks Kálmán! On Fri, Apr 24, 2020 at 8:31 PM Kálmán Viktor <[email protected]> wrote: > You can add it like this, not sure if this would help. (maybe wrap the > whole thing in an if that checks if you are on android or not) > > class QtHandler(logging.Handler): > def __init__(self): > logging.Handler.__init__(self) > self.qt_message_logger = QMessageLogger() > > def emit(self, record): > record = self.format(record) > # I think you can get log level from the record and use the > correct method of qt_message_logger based on that > self.qt_message_logger.debug(record.encode("utf-8")) > > qtHandler = QtHandler() > logger = logging.getLogger(__name__) > logger.addHandler(qtHandler) > > (forgot to include the list previously) > > Rodrigo Oliveira <[email protected]> ezt írta (időpont: 2020. > ápr. 20., H, 5:12): > >> Hi, I'm porting an existing application to Android. It's already working, >> but can't manage to print/log messages on logcat (Qt 5.12.3 (arm64_v8a), >> PyQt 5.12.3, sip 4.19.18 and pyqtdeploy 2.5.1). >> >> I can use 'console.log' from QML, but print and logging from python >> doesn't show on adb logcat. >> Also, tried qDebug, but the application crashes (QtCore is listed both on >> sysroot.json and on the pdy file. >> >> Anyone experimented or know how to solve this? Am I missing something? >> >> Many thanks, >> Rodrigo Oliveira >> _______________________________________________ >> PyQt mailing list [email protected] >> https://www.riverbankcomputing.com/mailman/listinfo/pyqt >> >