I've encountered the following integral while trying my hand at differentiating under the integral sign: $$-\int_{-\pi}^\pi\frac{x\sin ax}{2+\cos ax}\,dx$$ and I remember seeing something similar from my time taking complex analysis, but I can't for the life of me recall what kind of contour we had used for this type of integral. I remember there were certain tricks that might have involved the real/complex part of an exponential function, but I think that was used for integrands that resembled $\dfrac{\sin x}{x}$ as opposed to integrals of the form above.
The original integral was $\displaystyle \int_{-\pi}^\pi\ln(2+\cos x)\,dx$ (nothing special, just something I chose after Mathematica had told me it has a closed form), and I've considered parameterizations $$I(a)=\int_{-\pi}^\pi\ln(2+a\cos x)\,dx$$and$$J(a)=\int_{-\pi}^\pi\ln(2+\cos ax)\,dx$$ (The latter gives me the integral I'm attempting to compute.)
I'm far from mastering this method, so if I made a bad choice of parameter please let me know.
This is the closest thing I've found with a quick search that resembles this type of integral but it's quite different.
Edit: With some help from a friend I got an answer that makes use of the power series for the inverse hyperbolic secant function and logarithm, $$\newcommand{\arcsech}{\text{arcsech}} \arcsech x=\ln\frac{2}{x}-\sum_{n=1}^\infty \frac{(2n-1)!}{2^{2n}(n!)^2}x^{2n}$$ $$\ln(2+x)=\ln 2+\sum_{n=1}^\infty \frac{(-1)^{n-1}}{n2^n}x^n$$ From the log series we have $$\ln(2+\cos x)=\ln2+\sum _{n=1}^{\infty } \frac{(-1)^{n-1} \cos ^n(x)}{n 2^n}$$ Integrating over $[0,\pi]$ yields $$\int_0^\pi\ln(2+\cos x)=\pi\ln 2-\sum _{k=1}^{\infty } \frac{\displaystyle\int_0^{\pi } \cos ^{2 k}(x) \, dx}{(2 k) 2^{2 k}}$$ The sum of the odd $n$ terms disappears, and the sum of even $n$ terms can be rewritten; this is due to the following: $$\int_0^{\pi } \cos ^{2 k+1}(x) \, dx=0 \\ \int_0^{\pi } \cos ^{2 k}(x) \, dx=\frac{\pi (2 k)!}{2^{2 k} (k!)^2}$$ So, we have $$\int_0^\pi\ln(2+\cos x)=\pi \ln2-\pi\sum _{k=1}^{\infty } \frac{(2 k-1)!}{2^{4 k} (k!)^2}$$ Substituting $x=\dfrac{1}{2}$ into the inverse hyperbolic secant series gives $$\begin{align*}\arcsech \frac{1}{2}&=\ln4-\sum_{n=1}^\infty \frac{(2n-1)!}{2^{4n}(n!)^2}\\ \ln(2+\sqrt3)&=\cdots\\ \sum_{n=1}^\infty \frac{(2n-1)!}{2^{4n}(n!)^2}&=\ln(8-4\sqrt3) \end{align*}$$ It then follows that $$\begin{align*}\int_{-\pi}^\pi\ln(2+\cos x)\,dx&=2\big(\pi\ln2-\pi\ln(8-4\sqrt3)\big)\\ &=-2\pi\ln(4-2\sqrt3) \end{align*}$$
An antiderivative of $\ln(2 + \cos(x))$ is the non-elementary function $$ F(x) = \dfrac{i}{2}{x}^{2}+x\ln \left( 2+\cos \left( x \right) \right) -x\ln \left( 2+\sqrt {3} \right) -x\ln \left( 2-\sqrt {3}+{{\rm e}^{ix}} \right) -x\ln \left( 2-\sqrt {3} \right) -x\ln \left( 2+\sqrt {3}+{ {\rm e}^{ix}} \right) +i\;\text{dilog} \left( -{\frac {2-\sqrt {3}+{ {\rm e}^{ix}}}{-2+\sqrt {3}}} \right) +i\;\text{dilog} \left( {\frac {2+ \sqrt {3}+{{\rm e}^{ix}}}{2+\sqrt {3}}} \right) $$ So for $|a| < 1$, $$ J(a) = \int_{-\pi}^\pi \ln(2 + \cos(ax))\; dx = \dfrac{2}{a} \int_{0}^{\pi a} \ln(2 + \cos(t))\; dt = \dfrac{2}{a} (F(\pi a) - F(0)) $$ (the restriction on $|a|$ is needed because this form of $F$ has discontinuities at $\pi$ and $-\pi$).