3

I am writing a Qgis plugin. I would like the plugin to write log message in a specific tab, in the Log Messages window. I tried:

QgsMessageLog.logMessage("File "+ii.source()+": all pixels set to no data", 'Raster Processing',QgsMessageLog.INFO )

but QGis keeps on writing under tab "General". I suppose I'm missing an initialisation part to instantiate a new tab and connect it to the message logger?

1 Answer 1

4

Your command looks right to me, there should not be any special initialisation besides the import

from qgis.core import QgsMessageLog

Maybe try with defining tag and level as defined in the QGIS API Documentation:

QgsMessageLog.logMessage("File "+ii.source()+": all pixels set to no data", tag="Raster Processing", level=QgsMessageLog.INFO )
2
  • In my case, using tag and level keyword allowed the function to work. I did not need to import QgsMessageLog (I'm writting a plugin, I suppose it is imported by default...). Oct 28, 2015 at 15:01
  • 2
    For the QGIS 3 API, this should be QgsMessageLog.logMessage("File all pixels set to no data", "Raster Processing", level=Qgis.Info )
    – etrimaille
    Oct 29, 2019 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.