The line integral $\int_{\gamma}\frac 1z$ and branchs of logarithm 
Fix $w=re^{i\theta}\neq 0$ and let $\gamma$ be a rectifiable path in $\mathbb{C}\setminus\{0\}$ from $1$ to $w$. Show that there is a $k\in\mathbb{Z}$ such that $\displaystyle\int_{\gamma}\dfrac 1z=\log r+i\theta+2\pi i k$.

If we could find some primitive $F$ of $\dfrac 1z$, we would have $\displaystyle\int_{\gamma}\dfrac 1z=F(w)-F(1)$. If we could take $F(z)=\log z$, the principal branch, then $F(w)=\log r + i\theta$ and $F(1)=0$. But where does that $k\in\mathbb{Z}$ come from? It seems we can't take the principal branch so lightly.
How can we find a good primitive?
 A: Since the contour $\gamma$ is rectifiable, we can divide it into a finite number of segments.  We divide, therefore, $\gamma$ into $N$ segments such we can parameterize each segment with a single-valued, differentiable function.
On the $n$'th segment, $1\le n \le N$, we write $z$ as the single-valued differentiable function of the parameter $t$, $z_n(t)$, where $z_n(t)$ is given in polar form by
$$z=\rho_n(t)e^{i\phi_n(t)}$$
for $t_{n-1}\le t \le t_n$, with $0\le \phi_n(t)<2\pi$.  
On segment $n$, we have $dz=(\rho_n'(t)+i\rho_n(t)\phi'_n(t))e^{i\phi_n(t)}\,dt$ with $t$ starting at $t_{n-1}$ and ending at $t_{n}$.  Then, we can write
$$\begin{align}
\int_{\gamma}\dfrac{1}{z}\,dz&=\sum_{n=1}^{N}\int_{t_{n-1}}^{t_n} \dfrac{\rho'_n(t)+i\rho_n(t)\phi'_n(t)}{\rho_n(t)e^{i\phi_n(t)}}e^{i\phi_n(t)}\,dt\\\\
&=\sum_{n=1}^{N}\int_{t_{n-1}}^{t_n}\left(\dfrac{\rho'_n(t)}{\rho_n(t)}+i\phi'_n(t)\right)\,dt\\\\
&=\log(\rho(t_N)/\rho(t_0))+i\sum_{n=1}^{N}\left(\phi_n(t_{n})-\phi_n(t_{n-1})\right)\\\\
&=\log r + i \left(\phi_N(t_{N})-\phi_1(t_{0})\right)\\\\
&+i\sum_{i=1}^{N-1}\left(\phi_{n}(t_{n})-\phi_{n+1}(t_{n})\right) \tag 1
\end{align}$$
First, we note that $\phi_N(t_{N})=\theta$ and $\phi_1(t_{0})=0$ so that 
$$ \phi_N(t_{N})-\phi_1(t_{0})=\theta $$  
Next we note that, unless segments $n$ and $n+1$ together cross the real axis, we have
$$\phi_{n}(t_{n})-\phi_{n+1}(t_{n})=0 $$ 
Now, if the segments do constitute a crossing of the positive real axis, then either $\phi_{n}(t_{n})=2\pi$ and $\phi_{n+1}(t_{n})=0$ or $\phi_{n}(t_{n})=0$ and $\phi_{n+1}(t_{n})=2\pi$.  
Therefore, the sum of the right-hand side of $(1)$ is equal to $2\pi k$ where $k$ is the net number of times $\gamma$ crosses the positive real axis from the fourth quadrant to first quadrant.
Putting everything together, we obtain
$$\bbox[5px,border:2px solid #C0A000]{\int_{\gamma}\dfrac{1}{z}\,dz=\log r+i(\theta+2k\pi)}$$
as was to be shown!
