to make sense of this, you'll want to use the identity in integral form:

$\int_{-\infty}^{\infty}dx f(x) \frac{d}{dx}\log x=-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}$.