Format log messages