Solution (source code)

= Solution

The principal value is $\log z=\log|z|+i\operatorname{Arg}z$, where $-\pi\lt \operatorname{Arg}z\leq\pi$ and $z\ne0$.