[Qgis-developer] QgsMessageLog

Martin Dobias wonder.sk at gmail.com
Sat Apr 13 02:32:31 PDT 2013


On Sat, Apr 13, 2013 at 7:53 AM, Chris Crook <ccrook at linz.govt.nz> wrote:
> Hi
>
> I'm writing some test cases in python and want to trap messages sent to QgsMessageLog.  The C++ API docs state that there is a receivedMessage signal emitted by the QgsMessageLog, but it does not seem to be exposed to the Python API.
>
> Can anyone tell me either how to access the message log from python, or how to expose this signal so that I can use it.

Should be fixed in master now. This works for me:

def x(txt):
  print "log:", txt

from PyQt4.QtCore import *
QObject.connect(QgsMessageLog.instance(),
SIGNAL("messageReceived(QString,QString,QgsMessageLog::MessageLevel)"),
x)
QgsMessageLog.logMessage("test")

The last command will also print out "log: test"

Martin


More information about the Qgis-developer mailing list