Clean way to make log history

Hi, right now I use an old php script who connect to my mysql db but it does not always work so I search a beter way to make this in habpanel :

Thanks