Mathematica gives $$g(a)=\frac{\pi}{2} \, \text{sgn}(a) \ln(1+|a|) $$ for real $a$.
This can be obtained as follows: $g(0)=0$ and $$g'(a)=\int_0^{\pi/2}\frac{dx}{1+a^2\tan^2 x}=\int_0^\infty\frac{du}{(1+a^2u^2)(1+u^2)}=\frac\pi{2(1+|a|)}, $$ where we used the substitution $u=\tan x$; the latter integral can be taken by partial fraction decomposition.