Add logging of state changes.