I am having trouble understanding integrals of the form: $$\int_\gamma\frac{f'(z)}{f(z)}\,{\rm d}z$$I am aware that there are problems with the complex logarithm, and we have the formula: $$\oint_{\gamma}\frac{f'(z)}{f(z)}\,{\rm d}z = 2\pi i(Z(f,\gamma)-P(f,\gamma)),$$if $\gamma$ is a closed contour, where $Z(f,\gamma)$ is the number os zeros inside $\gamma$ counted with multiplicity, and the same thing for $P(f,\gamma)$ and poles. My trouble is pretty much as in this question, but the answers there aren't detailed enough.
I am sure my lack of understanding is conceptual, so I'll put here two or three examples (taken of my head) so you can pinpoint better what I am thinking wrong. I know about residue integration, but that I understand, so I won't use it.
Say I take $f(z) = z^2-1$, and $\gamma(t) = 2e^{it}$, with $0 \leq t \leq 2\pi$. By the formula, I expect the integral to be: $$\oint_\gamma \frac{2z}{z^2-1}\,{\rm d}z = 4\pi i$$ A direct computation gives me: $$\int_0^{2\pi}\frac{4e^{it}}{4e^{2it}-1}2ie^{it}\,{\rm d}t = \int_0^{2\pi}\frac{8ie^{2it}}{4e^{2it}-1}\,{\rm d}t \color{blue}{=} \ln(4e^{2it}-1)\big|_0^{2\pi} \color{red}{=} 0.$$
Another one: $f(z) = z^2-z-2$, and $\gamma(t) = 5e^{it}$, $0 \leq t \leq 2\pi$. Again I expect the integral to be $4\pi i$. But: $$\int_0^{2\pi}\frac{10e^{it}-1}{25e^{2it}-5e^{it}-2}5ie^{it}\,{\rm d}t \color{blue}{=} \ln(25e^{2it}-5e^{it}-2)\big|_0^{2\pi} \color{red}{=} 0.$$
In general: $$\int_\gamma \frac{f'(z)}{f(z)}\,{\rm d}z = \int_0^{2\pi}\frac{f'(re^{it})}{f(re^{it})}ire^{it}\,{\rm d}t \color{blue}{=} \ln(f(re^{it}))\big|_0^{2\pi} \color{red}{=}0$$
Right now I bet you're probably wanting to say that the complex logarithm is multivalued, and that's what's going wrong. This just doesn't cut it for me, because in the red $\color{red}{=}$, I'll keep getting the same damn point to evaluate the $\ln$.
And about the argument, in the other question they said something in the lines of breaking the integral into real and imaginary parts, the real parts cancelling, and we only having left something like: $$\arg(f(\gamma(t)))\big|_0^{2\pi},$$ and I know that this must be a multiple of $2\pi$, but I can't see how this comes up in the middle of the calculation.
I am terribly confused, the books all start hand-waving, and I don't find similar questions to this one, except the one I linked. Books don't give practical examples of the above situation, and the only one is that trivial $\int_\gamma 1/z \,{\rm d}z$ which does not clarify anything.
In the above examples, the mistake is in the $\color{blue}{=}$'s or in the $\color{red}{=}$'s? How that $\arg(f(z))\big|_\gamma$ being a multiple of $2\pi$ comes into the calculation? Is there any example?