How to find that improper integral? How to find the integral
 $$ \int\limits_0^\infty\left( \frac 1 {u^2}\ \log|1-u^2e^{2i\theta}| - \frac {\cos\theta} {u} \log\left| \frac {u-e^{i\theta}} {u+e^{i\theta}} \right| \right) \,du $$
  with $\theta \in [0,2\pi)$?
 A: That integral is best understood in terms of the Poisson kernel. We have:
$$\log\left|1-u^2 e^{2i\theta}\right| = \log\left|u-e^{i\theta}\right|+\log\left|u+e^{i\theta}\right|$$
hence:
$$\small{ I = \frac{1}{2}\int_{\mathbb{R}^+}\!\left(\frac{1}{u^2}-\frac{\cos\theta}{u^2}\right)\log(u^2-2u\cos\theta+1)+\left(\frac{1}{u^2}+\frac{\cos\theta}{u^2}\right)\log(u^2+2u\cos\theta+1)\,du}$$
and integration by parts leads to:
$$ I = 2\int_{0}^{+\infty}\frac{u^2-\cos(2\theta)+(u^2-1)\cos^2 t\log u }{u^4-2u^2\cos(2\theta)+1}\,du\tag{1}$$
so:
$$ I = \pi\sin\theta +2\cos^2\theta \int_{0}^{+\infty}\frac{(u^2-1)\log u}{u^4-2u^2\cos(2\theta)+1}\tag{2}$$
but:
$$\int_{0}^{+\infty}\frac{(u^2-1)\log u}{(u^2-e^{2i\theta})(u^2-e^{-2i\theta})}\,du\\ =\frac{e^{2i\theta}-1}{e^{2i\theta}-e^{-2i\theta}}\int_{0}^{+\infty}\frac{\log u}{u^2-e^{2i\theta}}\,du-\frac{e^{-2i\theta}-1}{e^{2i\theta}-e^{-2i\theta}}\int_{0}^{+\infty}\frac{\log u}{u^2-e^{-2i\theta}}\,du\\=2\cdot\text{Re}\left(\frac{e^{2i\theta}-1}{e^{2i\theta}-e^{-2i\theta}}\int_{0}^{+\infty}\frac{\log u}{u^2-e^{2i\theta}}\,du\right)\tag{3}$$
and:
$$\int_{0}^{+\infty}\frac{\log u}{u^2-e^{2i\theta}}\,du = e^{-i\theta}\left(\frac{\pi^2}{4}-\frac{\pi}{2}\bar{\theta}\right)\tag{4}$$
by the residue theorem, where $\bar\theta$ equals $\theta$ if $\theta\in[0,\pi)$, $\pi-2\theta$ otherwise.
By putting all together, we have:
$$ I = \pi\sin\theta+\left(\frac{\pi}{2}-\bar{\theta}\right)\pi\cos\theta.\tag{5}$$
