How did Euler prove the partial fraction expansion of the cotangent function: $\pi\cot(\pi z)=\frac1z+\sum_{k=1}^\infty(\frac1{z-k}+\frac1{z+k})$? As far as we know, Euler was the first to prove $$ \pi \cot(\pi z) = \frac{1}{z} + \sum_{k=1}^\infty \left( \frac{1}{z-k} + \frac{1}{z+k} \right).$$ I've seen several modern proofs of it and they all seem to rely either on the Herglotz trick or on the residue theorem. I recon Euler had neither nor at his disposal, so how did he prove it?
Added: Did Euler prove it for complex $z$ or just reals?
 A: Euler did have access to the infinite product representation of the sine function
$$\sin(\pi z)=\pi z\prod_{n=1}^{\infty}\left(1-\frac{z^2}{n^2}\right)$$
Then, we have
$$\begin{align}
\frac{d \log(\sin(\pi z))}{dz}&=\pi \cot(\pi z)\\\\
&=\frac1z+\sum_{n=1}^\infty \frac{2z}{z^2-n^2}\\\\
&=\frac1z+\sum_{n=1}^\infty \left(\frac{1}{z-n}+\frac{1}{z+n}\right)\\\\
\end{align}$$
as was to be shown!
A: In my opinion, Euler just considered the logarithmic derivative ($\frac{d}{dz}\log(\cdot)$) of both sides of
$$ \frac{\sin(\pi z)}{\pi z}=\prod_{n\geq 1}\left(1-\frac{z^2}{n^2}\right) \tag{1}$$
to derive the above identity, disregarding possible convergence issues. $(1)$ was well-known to him, and the key for his solution of the Basel problem. The possibility to apply the logarithmic derivative to both sides of $(1)$ follows from the whole Mittag-Leffler/Weierstrass products machinery.
It is possible to prove $(1)$ for $z\in\mathbb{R}$ (together with its uniform convergence over any compact subset of $\mathbb{R}$) by avoiding complex analysis, just exploiting the properties of Chebyshev polynomials of the second kind, but I am not so sure that Euler was aware of that (also because Chebyshev came about 100 years later than Euler).
