I was trying to understand contour integral which have or those involving branch cuts. Like $$I=\int_0^\infty\frac{dx}{x^3+1}$$ because the integrand is not even we cannot extend the integration to the whole real axis and then halve the result. However, suppose we look at the contour integral $$J=\oint_C\frac{\ln z \:dz}{x^3+1}$$ around the Keyhole contour. Everything seems nice until now. But then I get to know that "There is a connection between $J$ and the original definite integral $I$" $$J=2\pi iI$$ I get the partial intuition from one of M.SE answer, but couldn't understand the logic.
\begin{align}&\bbox[10px,#ffd]{\oint_C\frac{\ln z}{1+x^3}dz}=2\pi i\sum\text{Res}f(z)=\int_0^\infty\frac{\ln z}{1+z^3}dz+\int_\infty^0 \frac{\overbrace{\ln z+2\pi i}^\star}{1+z^3}dz=-2\pi i\int_0^\infty\frac{1}{1+z^3}dz\end{align}
Here I don't understand the $\star$. I think $\ln z=\ln r+i\theta+2\pi in$ used, but aren't we evaluate the integral on same branch? Then why to consider $2\pi i$?
Some contour integral which have branch cuts use wedge-shaped contour. Where $\Gamma = \Gamma_1 + \Gamma_2 + \Gamma_3$ going in a straight line $\Gamma_1$ from $0$ to $R$ on the real axis, then a circular arc $\Gamma_2$, then a straight line $\Gamma_3$ back to $0$. But I couldn't understand which angle I should use for $\Gamma_3$? Like for $f(z) = \frac{z^n}{1+z^m}$, it was suggested to use a wedge-shaped contour of angle $\frac{2\pi}{m}$.
Is there any trick or rule of thumb which help to decide the angle?