Computing $\int_{0}^{\pi}\ln\left(1-2a\cos x+a^2\right) \, dx$ 
For $a\ge 0$ let's define $$I(a)=\int_{0}^{\pi}\ln\left(1-2a\cos x+a^2\right)dx.$$ Find explicit formula for $I(a)$.

My attempt: Let
$$\begin{align*}
f_n(x)
&= \frac{\ln\left(1-2
\left(a+\frac{1}{n}\right)\cos x+\left(a+\frac{1}{n}\right)^2\right)-\ln\left(1-2a\cos x+a^2\right)}{\frac{1}{n}}\\
&=\frac{\ln\left(\displaystyle\frac{1-2
\left(a+\frac{1}{n}\right)\cos x+\left(a+\frac{1}{n}\right)^2}{1-2a\cos x+a^2}\right)}{\frac{1}{n}}\\
&=\frac{\ln\left(1+\dfrac{1}{n}\left(\displaystyle\frac{2a-2\cos x+\frac{1}{n}}{1-2a\cos x+a^2}\right)\right)}{\frac{1}{n}}.
\end{align*}$$
Now it is easy to see that $f_n(x) \to \frac{2a-2\cos x}{1-2a\cos x+a^2}$ as $n \to \infty$. $|f_n(x)|\le \frac{2a+2}{(1-a)^2}$ RHS is integrable so $\lim_{n\to\infty}\int_0^\pi f_n(x)dx = \int_0^\pi \frac{2a-2\cos x}{1-2a\cos x+a^2} dx=I'(a)$. But 
$$\int_0^\pi \frac{2a-2\cos x}{1-2a\cos x+a^2}=\int_0^\pi\left(1-\frac{(1-a)^2}{1-2a\cos x+a^2}\right)dx.$$ Consider
$$\int_0^\pi\frac{dx}{1-2a\cos x+a^2}=\int_0^\infty\frac{\frac{dy}{1+t^2}}{1-2a\frac{1-t^2}{1+t^2}+a^2}=\int_0^\infty\frac{dt}{1+t^2-2a(1-t^2)+a^2(1+t^2)}=\int_0^\infty\frac{dt}{(1-a)^2+\left((1+a)t\right)^2}\stackrel{(*)}{=}\frac{1}{(1-a)^2}\int_0^\infty\frac{dt}{1+\left(\frac{1+a}{1-a}t\right)^2}=\frac{1}{(1-a)(1+a)}\int_0^\infty\frac{du}{1+u^2}=\frac{1}{(1-a)(1+a)}\frac{\pi}{2}.$$
So $$I'(a)=\frac{\pi}{2}\left(2-\frac{1-a}{1+a}\right)\Rightarrow I(a)=\frac{\pi}{2}\left(3a-2\ln\left(a+1\right)\right).$$
It looks too easy, is there any crucial lack?
$(*)$ — we have to check $a=1$ here by hand and actually consider $[0,1), (1,\infty)$ but result on these two intervals may differ only by constant - it may be important but in my opinion not crucial for this proof.

If 
$$I(a)=\int_{0}^{\pi}\ln\left(1-2a\cos x+a^2\right)\ \mathrm{d}x,$$ then
\begin{align}
I'(a)&=\int_{0}^{\pi}\frac{2a-2\cos x}{1-2a\cos x+a^2} \ \mathrm{d}x,\\
I'(a) & = \frac{1}{a}\int_{0}^{\pi}\frac{2a^2-2a\cos x}{1-2a\cos x+a^2} \ \mathrm{d}x \\
& = \frac{1}{a}\int_{0}^{\pi}\frac{1-1+a^2+a^2-2a\cos x}{1-2a\cos x+a^2} \ \mathrm{d}x \\
& = {\pi \over a} + \frac{1}{a}\int_{0}^{\pi}\frac{a^2-1}{1-2a\cos x+a^2} \ \mathrm{d}x
\end{align}
and making the Weierstrass substitution, $$\cos x  = \frac{1 - t^2}{1 + t^2}, $$
$$\mathrm{d}x  = \frac{2 \,\mathrm{d}t}{1 + t^2}.$$
$$I'(a)={\pi \over a} + \frac{2}{a}\int_{0}^{\infty}\frac{a^2-1}{(1+a^2)(1+t^2)-2a(1-t^2)}\ \mathrm{d}t $$ $$I'(a)={\pi \over a} + \frac{2}{a}\int_{0}^{\infty}\frac{a^2-1}{(1-a)^2 + (1+a)^2t^2} \ \mathrm{d}t$$
$$I'(a)={\pi \over a} + \frac{\pi}{a} \operatorname{sgn} (a^2-1),$$
so for $a > 1$, 
$$I'(a)={2\pi \over a},$$
$$I(a)={2 \pi \log a},$$ given that $\displaystyle \lim_{a \rightarrow 1^+} I(a)=0$. You have to be careful to show this last statement I believe, but you can see the result here - this integral is easy to evaluate:
\begin{align}
\int_0^{\pi} \log(2-2\cos x) \ \mathrm{d}x &= \int_0^{\pi} \log(4 \sin^2 x) \ \mathrm{d}x \\
& = \pi \log 4 + 2\int_0^{\pi} \log(\sin x) \ \mathrm{d}x \\
& = 2\pi \log 2 + 4\int_0^{\pi/2} \log(\sin x) \ \mathrm{d}x \\
\end{align}
That final integral can be found here, which gives us the final result. 
