Avoid calling expensive methods before checking if we need to

There’s no need to create the full $record structure before checking for handlers. This can be called inside a loop, and Datetime::createFromFormat() is very expensive.
I extracted because it was breaking a unit test.

Basically, getLevelName() throws an Exception with invalid levels. 
If there's no handler, the execution won't get to the call and no exception is thrown.