Get the last Debug messeage

In my script I want to find out the last Log/Error in the Debug Console.
Is there a function for that? Or how should I do that?