Extracting Log_history through python script

Hello,
I am looking for an option to extract log file from robot controller through python. I want to do it with TCP IP.

Thanks in advance
Rohan