Derive with respect to $a$ and get
$$g'(a) = \int \limits _0 ^{\frac \pi 2} \frac {1 - a \cos x} {1 + a \cos x} \frac {\cos x (1 - a \cos x) + \cos x (1 + a \cos x) } {(1 - a \cos x)^2} \frac 1 {\cos x} \Bbb d x = 2 \int \limits _0 ^{\frac \pi 2} \frac 1 {1 - a^2 \cos ^2 x} .$$
Now, make the substitution $t = \tan x$, obtaining $\Bbb d x = \frac 1 {1 + t^2}$ and $\cos ^2 x = \frac 1 {1 + t^2}$, therefore you continue:
$$ g'(a) = 2 \int \limits _0 ^\infty \frac 1 {1 - \frac {a^2} {1+t^2}} \frac 1 {1+t^2} \Bbb d t = 2 \int \limits _0 ^\infty \frac 1 {(1-a^2) + t^2} = \frac 2 {\sqrt {1-a^2} } \arctan \frac t {\sqrt {1-a^2} } \Big| _0 ^\infty = \frac \pi {\sqrt {1-a^2} } .$$
Integrating now back with respect to $a$ you get:
$$g(a) = \pi \int \frac 1 {\sqrt {1-a^2}} \Bbb d a = \pi \arcsin a + C ,$$
with $C$ an integration constant.
Look back at the formula defining $g$ and note that $g(0) = 0$; on the other hand, according to our calculations, $g(0) = C$, so $C=0$ and finally
$$g(a) = \pi \arcsin a .$$
(Here $\log$ is the natural logarithm and we have used that $\log 1 = 0$.)
Edit:
The integral above is improper of the second type, apparently having a singularity in $\frac \pi 2$. In reality, the integrand is bounded and the integral converges because, applying l'Hospital's theorem,
$$\lim \limits _{x \to \frac \pi 2} \frac {\log \frac {1 + a \cos x} {1 - a \cos x}} {\cos x} = \lim \limits _{x \to \frac \pi 2} \frac {\frac {1 - a \cos x} {1 + a \cos x} \frac {- a \sin x (1 - a \cos x) - (1 + a\cos x) a \sin x} {(1-a \cos x)^2}} {- \sin x} = 2a .$$