[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] PyQt5/Android: print/log messages
From:       Rodrigo Oliveira <rodrigo.oliveira () byne ! com ! br>
Date:       2020-04-27 14:51:58
Message-ID: CAHhvZ=TrH8Ax5HV2ie1HixYnrwjoGZo+_XEPj4jRGMZOYiU+aQ () mail ! gmail ! com
[Download RAW message or body]

awesome, this works, thanks Kálmán!

On Fri, Apr 24, 2020 at 8:31 PM Kálmán Viktor <viktorvector@gmail.com>
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 <rodrigo.oliveira@byne.com.br> 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    PyQt@riverbankcomputing.com
>> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>

[Attachment #3 (text/html)]

<div dir="ltr"><div>awesome, this works, thanks  Kálmán!</div></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 24, 2020 at 8:31 PM \
Kálmán Viktor &lt;<a href="mailto:viktorvector@gmail.com" \
target="_blank">viktorvector@gmail.com</a>&gt; wrote:<br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div dir="ltr">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)<div><br></div><div>class QtHandler(logging.Handler):<br>      def \
__init__(self):<br>            logging.Handler.__init__(self)<br>            \
self.qt_message_logger = QMessageLogger()<br><br>      def emit(self, record):<br>    \
record = self.format(record)</div><div>            # I think you can get log level \
from  the record and use the correct method of qt_message_logger based on that<br>    \
self.qt_message_logger.debug(record.encode(&quot;utf-8&quot;))<br><br>qtHandler = \
QtHandler()<br>logger = \
logging.getLogger(__name__)<br>logger.addHandler(qtHandler)</div><div><br></div><div>(forgot \
to include the list previously)</div></div><br><div class="gmail_quote"><div \
dir="ltr" class="gmail_attr">Rodrigo Oliveira &lt;<a \
href="mailto:rodrigo.oliveira@byne.com.br" \
target="_blank">rodrigo.oliveira@byne.com.br</a>&gt; ezt írta (időpont: 2020. ápr. \
20., H, 5:12):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div \
dir="ltr"><div>Hi, I&#39;m porting an existing application to Android.  It&#39;s \
already working, but can&#39;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).</div><div><div><br></div><div>I can use &#39;console.log&#39; from QML, but \
print and logging from python doesn&#39;t show on adb logcat.</div><div>Also, tried \
qDebug, but the application crashes (QtCore is listed both on sysroot.json and on the \
pdy file.<br></div></div><div><br></div><div>Anyone experimented or know how to solve \
this? Am I missing something?</div><div><br></div><div>Many thanks,</div><div>Rodrigo \
Oliveira</div></div></div> _______________________________________________<br>
PyQt mailing list      <a href="mailto:PyQt@riverbankcomputing.com" \
target="_blank">PyQt@riverbankcomputing.com</a><br> <a \
href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" \
target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br> \
</blockquote></div> </blockquote></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic