I am trying to access the messages that was logged throughout a script.
arcpy.AddMessage("Something...")
message = arcpy.GetMessages()
print message # always empty
The above is always empty.
According to the documentation [
Creates a geoprocessing informative message (Severity=0) that can be accessed with any of the GetMessages functions.
Anyone have experience with arcpy know what the deal is?
1 Answer
arcpy.GetMessages() returns the messages from the last geoprocessing tool. If you run two tools and then call arcpy.GetMessages(), you will only get the messages from the second tool.
AddMessage is not a geoprocessing tool, so it will have no effects on GetMessages.
Basically, if you want to get all the messages from an entire script, you will have to call arcpy.GetMessages() after every geoprocessing tool call.