<s>[INST] Definite Integral involving logarithm and tangent function 
Show that
$$\mathcal{I}:=\int_0^{\frac{\pi}2} \log |1-a^2\tan^2\theta| d\theta= \pi\log\sqrt{a^2+1}.$$

I tried to use the substitution $\tan\theta=z$, to get that
$$\mathcal{I}:=\int_0^{\infty} \frac{\log|1-a^2z^2|}{z^2+1}dz$$
This integral is quite similar to this one:
Evaluating $\int_0^{\infty}\frac{\ln(x^2+1)}{x^2+1}dx$
However note that the sign inside the logarithm term is different and it seems none of the idea is applicable to this setting. May be there is a way to use the above link result to prove my integral. But I dont know.
Edit: Okay I think I have figured out one way to do it via contour integration. We can take a contour that looks like a large semicircle on the upper half plane so that it encloses only the pole at $z=i$. The contour should also have two holes around $z=\pm \frac1a$ to avoid the singularity coming from $\log$. Then Residue Calculus gives the desired result.
It would be nice to see a proof without residue calculus as well.
 [/INST] Note that we'll need to take the Cauchy Principal Value. Observe that by DUTIS,
\begin{align*}
    I(a) &= \int_0^{\frac{\pi}{2}} \ln\left|1-a^2\tan^2\theta\right|\,\mathrm{d}\theta\\
    I'(a) &= \int_0^{\frac{\pi}{2}} \frac{\partial}{\partial a} \ln\left|1-a^2\tan^2\theta\right|\,\mathrm{d}\theta\\
    &= \int_0^{\frac{\pi}{2}} \frac{2a \tan^2\theta}{a^2\tan^2\theta-1}\,\mathrm{d}\theta\\
    &= \frac{2}{a} \int_0^{\frac{\pi}{2}} 1 + \frac{1}{a^2 \tan^2\theta - 1} \,\mathrm{d}\theta\\\\
    &= \frac{2}{a} \left ( \lim_{\varepsilon\to 0} \int_0^{\cot^{-1} a - \varepsilon} 1 + \frac{1}{a^2 \tan^2\theta - 1} \, \mathrm{d}\theta + \int_{\cot^{-1} a + \varepsilon}^{\frac{\pi}{2}} 1 + \frac{1}{a^2 \tan^2\theta - 1} \, \mathrm{d}\theta \right ).\\
\end{align*}
so it is sufficient to evaluate the integral of $\dfrac{1}{a^2 \tan^2\theta - 1}$. We have
\begin{align*}
    \int \frac{1}{a^2 \tan^2\theta - 1} \, \mathrm{d}\theta &= \int \frac{1}{(u^2 + 1)(a^2 u^2 - 1)} \, \mathrm{d}u && \text{using $u = \tan\theta$}\\
    &= -\frac{1}{a^2 + 1} \int \frac{1}{u^2 + 1} \, \mathrm{d}u - \frac{a^2}{2(a^2 + 1)} \int \frac{1}{au+1} \, \mathrm{d}u + \frac{a^2}{2(a^2+1)} \int\frac{1}{au-1} \, \mathrm{d}u\\ 
    &= -\frac{\tan^{-1}(u)}{a^2 + 1} - \frac{a \ln |au + 1|}{2(a^2+1)} + \frac{a \ln |au - 1|}{2(a^2+1)} + C\\
    &= \frac{a \ln \left | \frac{a \tan\theta - 1}{a \tan\theta + 1} \right | - 2\theta}{2(a^2 + 1)} + C.
\end{align*}
Applying this to our original equation, we have
\begin{align*}
I'(a) &= \frac{2}{a} \left ( \lim_{\varepsilon\to 0} \left [\theta - \frac{a \ln \left | \frac{a \tan\theta - 1}{a \tan\theta + 1} \right | - 2\theta}{2(a^2 + 1)} \right ]_0^{\cot^{-1} a - \varepsilon} + \left [\theta - \frac{a \ln \left | \frac{a \tan\theta - 1}{a \tan\theta + 1} \right | - 2\theta}{2(a^2 + 1)} \right ]_{\cot^{-1} a + \varepsilon}^{\frac{\pi}{2}}\right )\\
&= \frac{2}{a} \left ( \lim_{\varepsilon\to 0} \frac{2a^2 \cot^{-1} a - 2a^2 \varepsilon - a \ln \left | \frac{-(a^2+1)\tan\varepsilon}{(1-a^2)\tan\varepsilon+2a}\right |}{2(a^2+1)} + \frac{a^2 \pi}{2(a^2+1)} - \frac{2a^2 \cot^{-1} a + 2a^2 \varepsilon - a \ln \left | \frac{(a^2+1)\tan\varepsilon}{(a^2-1)\tan\varepsilon+2a}\right |}{2(a^2 + 1)} \right )\\
&= \frac{2}{a} \left ( \lim_{\varepsilon\to 0} \frac{-4a^2 \varepsilon - a \ln \left | \frac{(1-a^2)\tan\varepsilon+2a}{(a^2-1)\tan\varepsilon+2a}\right |}{2(a^2+1)} + \frac{a^2 \pi}{2(a^2+1)}\right )\\
&= \frac{a \pi}{a^2 + 1}\\
\implies I(a) &= \int \frac{a\pi}{a^2+1} \, \mathrm{d}a\\
&= \pi \ln\sqrt{a^2 + 1} + C.
\end{align*}
Finally, observe $I(0) = 0$, so $C = 0$. Hence, $I(a) = \pi \ln\sqrt{a^2 + 1}$.
</s>