Closed form of $\int_0^\infty \ln \left( \frac{x^2+2kx\cos b+k^2}{x^2+2kx\cos a+k^2}\right) \;\frac{\mathrm dx}{x}$ Today I discussed the following integral in the chat room

$$\int_0^\infty  \ln \left( \frac{x^2+2kx\cos b+k^2}{x^2+2kx\cos a+k^2}\right) \;\frac{\mathrm dx}{x}$$
  where $0\leq a, b\leq \pi$ and $k>0$.

Some users suggested me that I can use Frullani's theorem:
$$\int_0^\infty \frac{f(ax) - f(bx)}{x} = \big[f(0) - f(\infty)\big]\ln \left(\frac ab\right)$$
So I tried to work with that way.
\begin{align}   I&=\int_0^\infty  \ln \left( \frac{x^2+2kx\cos b+k^2}{x^2+2kx\cos a+k^2}\right) \;\frac{\mathrm dx}{x}\\   &=\int_0^\infty \frac{\ln \left( x^2+2kx\cos b+k^2\right)-\ln \left( x^2+2kx\cos a+k^2\right)}{x}\mathrm dx\tag{1}\\   &=\int_0^\infty \frac{\ln \left( 1+\dfrac{2k\cos b}{x}+\dfrac{k^2}{x^2}\right)-\ln \left( 1+\dfrac{2k\cos a}{x}+\dfrac{k^2}{x^2}\right)}{x}\mathrm dx\tag{2}\\   \end{align}
The issue arose from $(1)$ because $f(\infty)$ diverges and the same issue arose from $(2)$ because $f(0)$ diverges. I then tried to use D.U.I.S. by differentiating w.r.t. $k$, but it seemed no hope because WolframAlpha gave me this horrible form. Any idea? Any help would be appreciated. Thanks in advance.

First note that by substituting $x\mapsto kx$, we get
$$
\int_0^\infty\log\left(\frac{x^2+2kx\cos(a)+k^2}{x^2+2kx\cos(b)+k^2}\right)\frac{\mathrm{d}x}{x}
=\int_0^\infty\log\left(\frac{x^2+2x\cos(a)+1}{x^2+2x\cos(b)+1}\right)\frac{\mathrm{d}x}{x}
$$
Let $u=\frac{x+\cos(a)}{\sin(a)}$. Then
$$
\begin{align}
\frac{\mathrm{d}}{\mathrm{d}a}\int_0^\infty\log\left(\frac{x^2+2x\cos(a)+1}{x^2+2x+1}\right)\frac{\mathrm{d}x}{x}
&=-2\int_0^\infty\frac{\sin(a)}{x^2+2x\cos(a)+1}\,\mathrm{d}x\\
&=-2\int_0^\infty\frac{\sin(a)}{(x+\cos(a))^2+\sin^2(a)}\,\mathrm{d}x\\
&=-\frac2{\sin(a)}\int_0^\infty\frac1{\frac{(x+\cos(a))^2}{\sin^2(a)}+1}\,\mathrm{d}x\\
&=-2\int_{\cot(a)}^\infty\frac1{u^2+1}\,\mathrm{d}u\\[9pt]
&=-2a
\end{align}
$$
Integrating in $a$ gives
$$
\int_0^\infty\log\left(\frac{x^2+2x\cos(a)+1}{x^2+2x+1}\right)\frac{\mathrm{d}x}{x}
=-a^2
$$
Therefore, by subtraction,
$$
\int_0^\infty\log\left(\frac{x^2+2kx\cos(a)+k^2}{x^2+2kx\cos(b)+k^2}\right)\frac{\mathrm{d}x}{x}
=b^2-a^2
$$
