We may consider tha meromorphic function $f(z)=\frac{1}{1-z^2}$. This function has simple poles at $z=\pm 1$, but it is a holomorphic function over the region $\left\{z:\left|\text{arg}\,z\right|\geq\varepsilon, \left|\pi-\text{arg}\,z\right|\geq\varepsilon\right\}$, for instance. It follows that for any $x\in(0,\pi)$
$$\begin{eqnarray*} \int_{0}^{e^{ix}}f(z)\,dz &=& \int_{0}^{i}f(z)\,dz + \int_{i}^{e^{ix}}f(z)\,dz\\ &=&\frac{i\pi}{4}+\int_{\pi/2}^{x}\frac{i e^{i\theta}}{1-e^{2i\theta}}\,d\theta\\&=&\frac{i\pi}{4}+\frac{1}{2}\int_{x}^{\pi/2}\frac{d\theta}{\sin\theta}\end{eqnarray*} $$
and in particular the imaginary part of the integral equals $\frac{\pi}{4}$.
On the other hand, as soon as $z$ lies in the previous region and in $\|z\|\leq 1$,
$$ f(z) = 1 + z^2 + z^4 + \ldots\qquad \int_0^z f(t)\,dt = z+\frac{z^3}{3}+\frac{z^5}{5}+\ldots $$
hence by considering $z=e^{ix}$ and switching to the imaginary parts:
$$ \sum_{n\geq 1}\frac{\sin((2n-1)x)}{2n-1}=\frac{\pi}{4}$$
as wanted. By considering the real parts, instead, we get:
$$ \forall x\in(0,\pi),\qquad \sum_{n\geq 1}\frac{\cos((2n-1)x)}{2n-1}=-\frac{1}{2}\log\tan\frac{x}{2}.$$
Unrelated, but interesting consequence: the functions $\frac{\pi}{2}$ and $-\log\tan\frac{t}{2}$ have the same $L^2$ norm over $(0,\pi)$, hence:
$$\begin{eqnarray*}\frac{\pi^3}{4}=\int_{0}^{\pi}\log^2\tan\left(\frac{t}{2}\right)\,dt &=& 2\int_{0}^{+\infty}\frac{\log^2(u)}{1+u^2}\,du=4\int_{0}^{1}\frac{\log^2(u)}{1+u^2}\,du\end{eqnarray*}$$
and since $\int_{0}^{1}u^{2k}\log^2(u)\,du = \frac{2}{(2k+1)^3}$,
$$\frac{\pi^3}{32}=\sum_{k\geq 0}\frac{(-1)^k}{(2k+1)^3},\qquad \frac{\pi}{2}\sum_{n\geq 0}\frac{1}{(2n+1)^2}=\frac{\pi^3}{16},$$
finding both the value of $\zeta(2)$ and the first case of this identity.