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.

Here is an elementary way to compute the integral.
First, let us prove some initial results.


*

*Making the substitution $x \mapsto \pi - x$ yields
$I(a) = \int^\pi_0 \log \left (1 + 2a\cos x + a^2 \right ) \, dx = I(-a)$
so that
$$I(a) = I(-a). \tag{$\dagger$}$$

*Then, consider
$$\begin{align*}
I(a) + I(-a)
&= \int^{\pi}_{0}\log \! \Big ( \left (1 - 2a\cos x + a^2 \right ) \left (1 + 2a\cos x + a^2 \right ) \Big) \> dx\\
&= \int^{\pi}_{0}\log \! \Big ( \left (1 + a^2 \right )^2 - \left (2a\cos x \right )^2 \Big) \> dx.\\
\end{align*}$$
Using double angle formulae produces
$$\begin{align*}
I(a) + I(-a)&= \int^{\pi}_{0}\log \left ( 1 + 2a^2 + a^4 - 2a^2 \left ( 1 + \cos 2x \right ) \right) \, dx\\
&= \int^{\pi}_{0}\log \left ( 1 - 2a^2\cos 2x + a^4 \right) \, dx,\\
\end{align*}$$
so we may let $x \mapsto \frac{1}{2}x$ to give
$$\begin{align*}
I(a) + I(-a) &= \frac{1}{2}\int^{2\pi}_{0}\log \left ( 1 - 2a^2\cos x + a^4 \right) \, dx.\\
\end{align*}$$
We can then split the integral at $\pi$ and set $x \mapsto 2\pi - x$ for the second integral:
$$\begin{align*}
I(a) + I(-a) &= \frac{1}{2} I(a^2) + \frac{1}{2}\int^{2\pi}_{\pi}\log \left ( 1 - 2a^2\cos x + a^4 \right) \, dx\\
&= \frac{1}{2} I(a^2) + \frac{1}{2}\int^{\pi}_{0}\log \left ( 1 - 2a^2\cos x + a^4 \right) \, dx\\
&= I(a^2).
\end{align*}$$
We thus have (applying $(\dagger)$)
$$I(a)= \frac{1}{2}I(a^2). \tag{$\star$}$$

It follows from $(\star)$ that $I(0) = 0$ and $I(1) = 0$.
Consider the case when $0 \le a < 1$. We may use $(\star)$ iteratively $n$ times to write
$$I(a) = \frac{1}{2^n} I \left ( a^{2^{n}} \right ). $$
Setting $n \to \infty$ allows $\frac{1}{2^n} \to 0$ and $a^{2^{n}} \to 0$ so that $I \left ( a^{2^{n}} \right ) \to 0$ which gives the result
$$ I(a) = 0. $$
When $a > 1$, it follows that $0 < 1/a < 1$ and consequently $I(1/a) = 0$. We have
$$\begin{align*}
I(a) &= \int^\pi_0 \log \! \Big ( a^2 \left ((1/a)^2 + (1/a)\cos x + 1 \right ) \Big ) \> dx\\
&= 2\pi\log(a) + I(1/a)\\
&= 2\pi\log\left(a\right).
\end{align*}$$
We could use $(\dagger)$ to extend the result to negative $a$, obtaining the final solution valid for all real $a$,
$$I(a) = 
\begin{cases}
0 &\text{if } |a| \le 1;\\
2\pi\log|a| &\text{otherwise}.
\end{cases}$$
