Re: PyQt5/Android: print/log messages

Kálmán Viktor <[email protected]> Sat, 25 Apr 2020 01:30:50 +0200
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <CA+sJfQzSpC8upcNP4oa8MZusuOp1KtnumoBFYk9GRiv5Qo8Btg@mail.gmail.com>
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
>

_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt