Simplifying $i \left[ \ln(x+i)-\ln(x-i)-\ln(1+ix)+\ln(1-ix) \right]$
Using the exponential form of $\tan{(x)}$ one can prove that $$\arctan{(x)}=\frac{i}2(\ln{(1-ix)}-\ln{(1+ix)})$$ Using the principal valued logarithm we can write $$\ln{(1+ix)}=\ln{(x-i)}+\ln{(i)}=\ln{(x-i)}+\frac{i\pi}2$$ $$\ln{(1-ix)}=\ln{(x+i)}+\ln{(-i)}=\ln{(x+i)}-\frac{i\pi}2$$ Hence we can rewrite the inverse tangent function as $$\begin{align} \arctan{(x)} &=\frac{i}2\left(\ln{(x+i)}-\frac{i\pi}2-\left(\ln{(x-i)}+\frac{i\pi}2\right)\right)\\ &=\frac{i}2\left(\ln{(x+i)}-\ln{(x-i)}-i\pi\right)\\ &=\frac{\pi}2+\frac{i}2\left(\ln{(x+i)}-\ln{(x-i)}\right)\\ \end{align}$$ Hence the given function is $$f(x)=2\left(\arctan{(x)}-\frac{\pi}2\right)+2\arctan{(x)}=4\arctan{(x)}-\pi$$
We have that
$$f(x) = i \left[ \ln(x+i)-\ln(x-i)-\ln(1+ix)+\ln(1-ix) \right] =\\= i \left[\ln i-\ln i +\ln(1-ix)-\ln(-1-ix)-\ln(1+ix)+\ln(1-ix) \right]=$$
$$= i \left[2\ln(1-ix)+\ln (-1)-\ln(1+ix)-\ln(1+ix) \right]=$$
$$= i \left[2\ln(1-ix)-2\ln(1+ix)+\ln (-1) \right]=2i\ln\left(\frac{1-ix}{1+ix}\right)+2i\ln i$$
then refer to Logarithmic forms.
We can use the definition of a branch cut of log for positive real part:
$$\text{Log}_k( z) = \log |z| + i \tan^{-1}\left(\frac{\text{Im}(z)}{\text{Re}(z)}\right)+i2\pi k$$
for $k\in\mathbb{Z}$. The principal branch of log is given by $k=0$. We can show the expression above has the same value no matter the branch. Plugging things in we have:
$$i\Bigr[i\tan^{-1}\left(\frac{1}{x}\right) - i\tan^{-1}\left(-\frac{1}{x}\right) - i\tan^{-1}(x) + i\tan^{-1}(-x)\Bigr]$$
$$= 2\Biggr[\tan^{-1}(x)-\tan^{-1}\left(\frac{1}{x}\right)\Biggr]$$
Since all of the magnitudes were identical, they canceled. Then we can use the fact that $\tan^{-1}(x) + \tan^{-1}\left(\frac{1}{x}\right) = \frac{\pi}{2}$ for $x>0$:
$$= 2\Biggr[2\tan^{-1}(x) - \tan^{-1}(x) - \tan^{-1}\left(\frac{1}{x}\right)\Biggr] = 4\tan^{-1}(x)-\pi$$