In a paper titled General Theorems in Contour Integration with Some Applications, G.H. Hardy states the following:
Let us integrate
$$ (i) \ \int \frac{e^{ipz}}{(\cos z)^{a}} \frac{\mathrm dz}{z- \xi} \, , $$
$$ (ii) \ \int \frac{e^{ipz}}{(\sin z)^{a}} \frac{\mathrm dz}{z- \xi} \, , $$
round contours $K'$. For the present we suppose $\xi$ not real, and $a <1 ,0 < p + a$; $a$ may be negative. We begin with $(i)$, taking that value of $(\cos z)^{a}$ which is real at the origin.
As $z$ moves around any one of the points $ \left( n+\frac{1}{2} \right) \pi$, the subject of integration acquires a factor $e^{ ia \pi}$; and so the contribution of $\Xi$ is, in the limit,
$$ \sum_{n=-\infty}^{\infty} \int^{(n+\frac{1}{2})\pi}_{(n-\frac{1}{2}) \pi} \frac{e^{i(na \pi + p x)} }{|\cos x |^{a}} \frac{\mathrm dx}{x-\xi} \, ,$$
or $$\sum_{n=-\infty}^{\infty} \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \frac{e^{ipu}}{(\cos u)^{a}} \frac{e^{i n \pi(p+a)}}{u+n \pi - \xi} \, \mathrm du.$$
The contour $K'$ is a closed semicircle in the upper half-plane, and $\Xi$ is the part of the contour that lies just above the real axis.
Since $$ \frac{1}{(\cos z)^{a}} = \frac{e^{-ia \arg (\cos z)}}{|\cos z |^{a}} \, ,$$ Hardy seems to be saying that $\arg (\cos z) = - n \pi$ on $\Xi$ if $\Re(z) \in \Big( \left(n-\frac{1}{2}\right) \pi, \left(n+ \frac{1}{2} \right)\pi \Big)$.
How exactly is $\log (\cos z)$ being defined here?
The author seems to be using branch cuts along the real axis where $|x|\ge\pi/2$. With this branch cut, $\log(\cos(z))$ would be defined by integrating $-\tan(z)$ from $z=0$ (where $\log(\cos(0))=0$). Then $$ \cos(z)^a=e^{a\log(\cos(z))} $$ As the point on $\Xi$ passes $\left(n+\tfrac12\right)\pi$, $\log(\cos(z))$ decreases by $\pi i$ (since $-\tan(z)$ has residue $1$ and the contour by passes in a clockwise semi-circle).
$\hspace{3cm}$
Thus, along $\Xi$, $$ \cos(z)^a= \begin{array}{} |\cos(z)|^ae^{-ian\pi}&\text{if }\mathrm{Re}(z)\in\left[\left(n-\tfrac12\right)\pi,\left(n+\tfrac12\right)\pi\right] \end{array} $$