Evaluate $\int\frac{\cot x}{\cos^2 x-\cos x+1}\,\,dx$ $$\int\frac{\cot x}{\cos^2 x-\cos x+1}\,\,dx$$
Please guide me by which term it should be substituted to get the result of this integration. I have tried it by using $\cos x =t$, but it went so long and more problematic.

Hint :
\begin{align}
\int\frac{\cot x}{\cos^2 x-\cos x+1}\;\mathrm dx&=\int\frac{\frac{\cos x}{\sin x}}{\cos^2 x-\cos x+1}\cdot\frac{\sin^2 x}{\sin^2 x}\;\mathrm dx\\[10pt]
&=\int\frac{\cos x}{\cos^2 x-\cos x+1}\cdot\frac{\sin  x}{1-\cos^2 x}\;\mathrm dx\\[10pt]
&=\int\frac{y}{y^2 -y+1}\cdot\frac{\mathrm dy}{y^2 - 1}\qquad\Rightarrow\qquad\text{set}\;y=\cos x\\[10pt]
&=-\frac{1}{3}\underbrace{\int\frac{2y-1}{y^2 -y+1}\mathrm dy}_{\large\color{red}{\text{set}\;t\,=\,y^2 -y+1}}+\frac{1}{2}\underbrace{\int\frac{\mathrm dy}{y-1}}_{\large\color{red}{\text{set}\;u\,=\,y-1}}+\frac{1}{6}\underbrace{\int\frac{\mathrm dy}{y+1}}_{\large\color{red}{\text{set}\;v\,=\,y+1}}
\end{align}
