How do I get the Info window's log text with Python?

I'm creating a Blender addon, however, I do not know how to access the 'INFO' (The window you drag from the top) windows log text.

If I could access that, I could create logs and such. I've tried lots of things, however, I couldn't crack it. Is there any way to get the text of the 'INFO' window?

• Just throwing this out...you can press "A" to select all, then copy/paste. (I know this is a lot more engaging actually putting it into practice, but I don't have time to do so right now) – JakeD Sep 5 '16 at 2:01
• Run bpy.ops.ui.reports_to_textblock() from the console. Creates a text block "Recent Reports". – batFINGER Sep 5 '16 at 5:46
• @batFinger You should make that an answer. @everyone I will add that you can get a string of text by using bpy.data.texts["Recent Reports"].as_string provided that there is only one text block named "Recent Reports" (to avoid "Recent Reports.001" auto-numbering problems) – JakeD Sep 5 '16 at 11:32
• Thank you so much! Yes batFinger please make that answer, along with pycoders adjustment ;) – Coolq B Sep 6 '16 at 1:53
• Do you know how to overwrite the file instead of creating new ones like Recent Reports.001 ? – Coolq B Sep 6 '16 at 2:16

Reports to text block operator bpy.ops.ui.reports_to_textblock() .

The operator bpy.ops.ui.reports_to_textblock() lists reports from the info area

into a text block named "Recent Reports"([.nnn] if run more than once.)

Test code. Removes existing recent reports before running operator.

#remove other Recent Reports