We know that $m \leq n \cdot (n-1) / 2 $ is $ O(n^2)$. It follows, therefore, that $O(\log (n^2)) = O(2\log n)=O(\log n)$.