[QGIS-Developer] URL/Request logging of QGIS?

Richard Duivenvoorde rdmailings at duif.net
Fri Oct 19 02:59:32 PDT 2018


On 10/19/2018 01:42 AM, Nyall Dawson wrote:
> On Thu, 18 Oct 2018 at 21:25, Richard Duivenvoorde <rdmailings at duif.net> wrote:
>> Thinking about a 'Requests'-tab in the Log Messages where you can maybe
>> disable/enable the logging of certain types of requests. Or where you
>> can filter certain types of requests.
>>
>> Is this doable? An idea?
> 
> Doable. Just better make sure that NONE of this would be exposed via
> Python, as potentially that's a large security risk. (Plugins
> listening in to all network requests happening, including
> authenticated requests...)

Not sure about the large security risk?

Ok, a quick stab, add into the Python console
(choose the print or logMessage line to your preference)


def request(operation, request, data):
    print('# Request: ', request.url())
     QgsMessageLog.logMessage('{}'.format(msg), self.MSG_TITLE, Qgis.Info)
def response(reply):
    print('# Response: ', reply.url())
    QgsMessageLog.logMessage('Response: {}'.format(reply.url()),
'NetworkRequests', Qgis.Info)

def timeout(reply):
    print('# Timeout: ', reply.url())
   QgsMessageLog.logMessage('Response: {}'.format(reply.url()),
'NetworkRequests', Qgis.Info)

nam=QgsNetworkAccessManager.instance()

nam.requestAboutToBeCreated.connect(request)
nam.requestCreated.connect(response)
nam.requestTimedOut.connect(timeout)



Some questions that come up, will dive into it deeper, but if somebody
has a hint, let me know plz:

- why do I not see WMS firing it's GetMap requests, while all other
requests of the WMS provider are there (legends, capabilities,
getfeatureinfo)
Something to do with handling in another thread?
Can we also show those?

- (having WCS troubles) looking at the Python Console the WCS provider
is firing A LOT of requests. But I have to look into what the responses
are, maybe it is just a http connection which is sending parts or so??

Anyway, I'm aware that this is the very first begin, I know that a lot
can go wrong with http requests, so we could show much more from the
Response objects...

I could start with a minimal Python plugin?

Using current QgsMessageLog would benefit a lot from for example
using/showing one tab (so not switch to another one just because that
one received some info).
Another feature request would be to be able to filter the messages there
(eg only show the wms or getMap or ... requests).

And off course, all this only works for code that actually uses the
QgsNetworkAccessManager (/me hoping I get WMS also working).
So again a FeatureRequest for a common Python codebase to actually use
the QgsNetworkAccessManager, so people do not use Requests or urllib3 or
so....

Anybody has some input?

Regards,

Richard Duivenvoorde



More information about the QGIS-Developer mailing list