In integral form, this amounts to the Sokhotski–PellmellSokhotski-Plemelj theorem:
$\lim_{\epsilon\rightarrow 0^{+}}\int_{-\infty}^{\infty}dx f(x) \frac{d}{dx}\log (x+i\epsilon)=-i\pi f(0)+{\cal P}\int_{-\infty}^{\infty}dx f(x)\frac{1}{x}$.
The symbol ${\cal P}$ indicates that the Cauchy principal value of the integral is to be taken. Formalization then amounts to stating the conditions on $f$ so that the principal value integral exists.
The logarithm for $x<0$ is defined as $\log x= \log(-x) + i\pi$. You can avoid the delta function by including the absolute value signs in the logarithm:
$\int_{-\infty}^{\infty}dx f(x) \frac{d}{dx}\log|x|={\cal P}\int_{-\infty}^{\infty}dx f(x)\frac{1}{x}$.