branches of log / residues My question is in regards to  Marko Riedel's answer to  the following integral question:
Real integral by keyhole contour
So, I was calculating the residues of
$$f(z) = \frac{\log^2 z}{z^2+2z+2}$$
so the poles are at $$\rho_{0,1} = -1 \pm i.$$,
both are simple so we can use
$$\mathrm{Res}\left(\frac{\log^2 z}{z^2+2z+2}; z = -1 + i\right)
= \frac{1}{2i} \log^2(-1+i)$$
and $$\mathrm{Res}\left(\frac{\log^2 z}{z^2+2z+2}; z = -1 - i\right)
= - \frac{1}{2i} \log^2(-1-i)$$
to calculate them.
However, this is when my confusion starts, when calculating $ \log^2(-1+i)$ and $ \log^2(-1-i)$ we can see that $r=|z|=\sqrt{(-1)^2+i^2}=\sqrt{2}$, but when calculating $Arg (z)$ with this https://en.wikipedia.org/wiki/Atan2 formula I get another result, I can not understand which branch he used. He states that the cut is along the positive axis, so Arg z must lie between $[0, 2\pi)$.
for: $ \log^2(-1+i)$:
$\arctan(-1/1)=\frac{-\pi}{4}$
and for
$ \log^2(-1-i)$
$\arctan(1/1)=\frac{\pi}{4}$
what the answer says:

$$\log^2(-1+i) =  \left(\frac{1}{2}\log 2 + \frac{3}{4} i\pi\right)^2
> $$


$$\log^2(-1-i) =\left(\frac{1}{2}\log{2} + \frac{5}{4} i\pi\right)^2
> $$

so it looks like he added $\pi$ to both $\arctan$ results to yield $3/4 \pi $ resp. $5/4 \pi$, but why? aren't they in different quadrants?
https://math.stackexchange.com/posts/621665/
 A: Too long for a comment
When you use the cut $[0;\infty)$ to make the integrand a single-valued function, you fix the view of all complex numbers in the complex plane.
In your case, the poles are: $-1+i=\sqrt2\,e^\frac{3\pi i}{4};\,\, -1-i=\sqrt2\,e^\frac{5\pi i}{4}$ - you define the angle, turning from the cut (axis X) counter-clockwise. You should use only these forms in further calculations.
In my opinion, it is more convenient to use $z^s$ instead of $\ln z$ in the integrand: the evaluation becomes more straightforward and you catch the inherent symmetry, what, in turns, allows to evaluate more complicated integrals.
Let's consider $\displaystyle I(a,b)=\int_0^\infty\frac{x^s}{(x-a)(x-b)}dx$, where $a, b$ are some complex numbers,
which can be presented as $a=\rho_1e^{i\phi_1}$ and $b=\rho_2e^{i\phi_2}\, (\rho, \phi$ are real).
Then $\,\,\displaystyle I_k(a,b)=\int_0^\infty\frac{\ln^kx}{(x-a)(x-b)}dx=\frac{\partial ^k}{\partial s^k}I(a,b)\,\bigg|_{s=0},\, \,k=0,1,2...\tag{1}$
$$I(a,b)=\int_0^\infty\frac{x^s}{(x-\rho_1e^{i\phi_1})(x-\rho_2e^{i\phi_2})}dx$$
Using a keyhole contour
$$I(1-e^{2\pi is})=2\pi i\frac{\rho_1^se^{i\phi_1s}-\rho_2^se^{i\phi_2s}}{\rho_1e^{i\phi_1}-\rho_2e^{i\phi_2}}\,\,\Rightarrow\,\,I=\pi \frac{e^{-\pi is}}{\sin\pi s}\frac{\rho_2^se^{i\phi_2s}-\rho_1^se^{i\phi_1s}}{\rho_1e^{i\phi_1}-\rho_2e^{i\phi_2}}$$
If $\rho_1=\rho_2=\rho$ (this exactly our case)
$$I=\pi \frac{e^{-\pi is}\rho^{s-1}}{\sin\pi s}\frac{e^{i\phi_2s}-e^{i\phi_1s}}{e^{i\phi_1}-e^{i\phi_2}}$$
We can simplify this general expression, or just take (for our case) $\rho=\sqrt2;\, \phi_1=\frac{3\pi i}{4};\,\phi_2=\frac{5\pi i}{4}$
$$I=\pi\frac{2^\frac{s-1}{2}}{\sin\pi s}\frac{e^\frac{\pi is}{4}-e^{-\frac{\pi is}{4}}}{e^\frac{\pi i}{4}-e^{-\frac{\pi i}{4}}}=\frac{\pi}{\sqrt2\sin\frac{\pi}{4}}\frac{2^\frac{s}{2}\sin\frac{\pi s}{4}}{\sin\pi s}=\pi\frac{2^\frac{s}{2}\sin\frac{\pi s}{4}}{\sin\pi s}\tag{2}$$
$$\boxed{\,\,I_k=\pi\frac{\partial ^k}{\partial s^k}\frac{2^\frac{s}{2}\sin\frac{\pi s}{4}}{\sin\pi s}\,\bigg|_{s=0}\,\,}\tag{3}$$
This expression is real; we do not have to care about the choice of logarithm branches. Taking the derivatives, or just decomposing the function near $s=0$
$$\pi\ \frac{2^\frac{s}{2}\sin\frac{\pi s}{4}}{\sin\pi s}=\frac{\pi}{4}\Big(1+\frac{\ln2}{2}s+\frac{\ln^22}{8}s^2+\frac{\ln^32}{48}s^3+...\Big)\frac{1-\big(\frac{\pi}{4}\big)^2\frac{s^2}{6}+...}{1-\frac{\pi^2}{6}s^2+...}$$
... we easily get for several first integrals:
$$I_0=\int_0^\infty\frac{dx}{x^2+2x+2}=\frac{\pi}{4}$$
$$I_1=\int_0^\infty\frac{\ln x}{x^2+2x+2}dx=\frac{\pi\ln2}{8}$$
$$I_2=\int_0^\infty\frac{\ln^2 x}{x^2+2x+2}dx=\frac{\pi}{16}\Big(\ln^22+\frac{5\pi^2}{4}\Big)$$
$$I_3=\int_0^\infty\frac{\ln^3 x}{x^2+2x+2}dx=\frac{15\pi^3\ln2}{128}+\frac{\pi\ln^32}{32}$$
etc.
