Which integration formula for $\frac{1}{a^2-x^2}$ is correct? In my book integration formula for $\frac{1}{x^2-a^2}$ is given as $\frac{1}{2a}\ln(\frac{x-a}{x+a})$.
From the above formula we can write the formula for integration of $\frac{1}{a^2-x^2}$ as   $-\frac{1}{2a}\ln(\frac{x-a}{x+a}) = \frac{1}{2a}\ln(\frac{x+a}{x-a}) $ [as we know $\ln(\frac{1}{x})=-\ln(x)$]
But, in my book the integration of  $\frac{1}{a^2-x^2}$ is written as $\frac{1}{2a}\ln(\frac{x+a}{{a-x}}) $.
We know that the integration in the second case cannot be $\frac{1}{2a}\ln(\frac{x+a}{x-a}) $ and $\frac{1}{2a}\ln(\frac{x+a}{{a-x}}) $ at the same time. Which formula is the correct one and why?

WLOG, $a>0$. As there are singularities at $x=-a$ and $x=a$, the expressions can differ in the intervals $(-\infty,-a)$, $(-a,a)$ and $(a,\infty)$, depending on the signs of $x+a$ and $x-a$.
Correct expressions are
$$\int\frac{dx}{x^2-a^2}=\frac1{2a}\log\left|\frac{x+a}{x-a}\right|=\frac1{2a}\log\left|\frac{a+x}{a-x}\right|.$$
(But you are not allowed to evaluate the definite integrals across the singularities.)
Then the effect of a change of sign is
$$\int\frac{dx}{a^2-x^2}=-\frac1{2a}\log\left|\frac{x+a}{x-a}\right|=\frac1{2a}\log\left|\frac{x-a}{x+a}\right|=\frac1{2a}\log\left|\frac{a-x}{a+x}\right|.$$
