What do $\int_{-1}^1\frac{dx}{2x+1-2i}$ and $\frac12\log(2x+1-2i)$ mean? Suppose we want to evaluate
$$I=\oint_C\frac{dz}{z+\frac12}$$
where $C$ is the unit square with diagonal corners at $-1-i$ and $1+i$. If we let $z:=re^{it}-\frac12$, then
$$I=\int_0^{2\pi}\frac{2rie^{it}}{2re^{it}-1+1}dt=2i\pi$$
but one way in my textbook is to let $z:=x+iy,dz=dx+idy$, in this case
$$I=\int_{-1}^1\frac{2dx}{2x+1-2i}+\int_{-1}^1\frac{2idy}{3+2iy}+\int_1^{-1}\frac{2dx}{2x+1+2i}+\int_1^{-1}\frac{2idy}{-1+2iy}$$
Now, for example, in first integral can we write
$$\int_{-1}^1\frac{dx}{2x+1-2i}=\frac12\log(2x+1-2i)|_{-1}^1=\frac12\log(3-2i)-\frac12\log(-1-2i)?$$
$\frac{dx}{2x+1-2i}$ is a function from $\mathbb R$ to $\mathbb C$ and I used techniques of real integration to find antidervative, so I can't understand that if this can be true or this $\log$ is a real logarithm or complex?? and if this is true, then by summing these four integrals, we arrive to $0\neq 2i\pi$? So what do
$$\int_{-1}^1\frac{dx}{2x+1-2i}\,\textrm{and}\,\frac12\log(2x+1-2i)$$
mean??
 A: Let $I$ be the contour integral defined by
$$\begin{align}
I&=\oint_C \frac{1}{z+1/2}\,dz\\\\
&=\int_{-1}^1 \frac{1}{(x+1/2)-i}\,dx+\int_{-1}^1 \frac{1}{3/2+iy}\,i\,dy\\\\
&-\int_{-1}^1 \frac{1}{(x+1/2)+i}\,dx-\int_{-1}^1 \frac{1}{-1/2+iy}\,i\,dy \tag 1
\end{align}$$
We can proceed using real analysis.  Proceeding accordingly, we can write $I$ in $(1)$ as
$$\begin{align}
I&=\int_{-1}^1 \frac{(x+1/2)+i}{(x+1/2)^2+1}\,dx+\int_{-1}^1 \frac{3/2-iy}{(3/2)^2+y^2}\,i\,dy\\\\
&-\int_{-1}^1 \frac{(x+1/2)-i}{(x+1/2)^2+1}\,dx-\int_{-1}^1 \frac{-1/2+iy}{(1/2)^2+y^2}\,i\,dy \\\\
&=2i\int_{-1}^1 \frac{1}{(x+1/2)^2+1}\,dx+\frac32 i \int_{-1}^1 \frac{1}{(3/2)^2+y^2}\,dy+\frac12 i\int_{-1}^1\frac{1}{(1/2)^2+y^2}\,dy\\\\
&=2i(\arctan(3/2)+\arctan(1/2))+2i\arctan(2/3)+2i\arctan(2)\\\\
&=2i\pi
\end{align}$$
as expected!

Alternatively, we can evaluate each of the integrals in $(1)$ using the complex logarithm function.  To do so requires choosing a branch cut to ensure that the logarithm is single valued.  We choose the branch cut of $\log(z)$ for the  principal branch of the logarithm, taken along the negative real axis.  There, we have
$$\log(z)=\log(|z|)+i\arg(z) \tag{$|z|>0,-\pi\le \arg(z)< \pi$}$$
Note from $(1)$ that the integration path $C$ crosses the chosen branch cut at $z=-1$.  Therefore, we need to evaluate the fourth integral on the right-hand side of $(1)$ as follows.
$$\begin{align}
\int_{-1}^1 \frac{1}{-1/2+iy}\,i\,dy&=\int_{-1}^{0^-}\frac{1}{-1/2+iy}\,i\,dy+\int_{0^+}^{1}\frac{1}{-1/2+iy}\,i\,dy\\\\
&=\log(-1/2+i0^-)-\log(-1/2-i)+\log(-1/2+i)-\log(-1/2+i0^+)\\\\
&=\log(1/2)-i\pi-\log(-1/2+i)+\log(-1/2+i)-\log(1/2)-i\pi\\\\
&=-2i\pi -\log(-1/2+i)+\log(-1/2+i) \tag 2
\end{align}$$
The first, second, and third integrals in $(1)$ are respectively   
$$\begin{align}
\int_{-1}^1 \frac{1}{(x+1/2)-i}\,dx&=\log(3/2-i)-\log(-1/2-i) \tag 3\\\\
\int_{-1}^1 \frac{1}{(x+1/2)+i}\,dx&=\log(3/2+i)-\log(-1/2+i)\tag 4\\\\
\int_{-1}^1 \frac{1}{3/2+iy}\,i\,dy&=\log(3/2+i)-\log(3/2-i) \tag 5\\\\
\end{align}$$
Substituting $(2)-(5)$ into $(1)$, we find that
$$I=2\pi i$$
thereby recovering the result obtained with real analysis!
