Seeing all those terms containing $e$ and $i$ makes it only logical to write cosine with its exponential definition .
$$I= -\int \log\left(\cos\left(x\right)\right) \, \mathrm{d}x + \int x \, \mathrm{d}x + \int \frac{1}{x} \, \mathrm{d}x=-\underbrace{\int \log\left(\cos\left(x\right)\right) \, \mathrm{d}x}_{I_1}+\frac12x^2+\log(x)+C_1$$
Now focusing on $I_1$, $$I_1= \int \log\left(\frac{\mathrm{e}^{\mathrm{i}x} + \mathrm{e}^{-\mathrm{i}x}}{2}\right) \, \mathrm{d}x\stackrel{u=ix}{=} -\mathrm{i} \int \left(\log\left(\mathrm{e}^{u} + \mathrm{e}^{-u}\right) - \log\left(2\right)\right)\mathrm{d}u\\\stackrel{IBP}{=} -i\left(u \log\left(\mathrm{e}^{u} + \mathrm{e}^{-u}\right) - \underbrace{\int \frac{u \left(\mathrm{e}^{u} - \mathrm{e}^{-u}\right)}{\mathrm{e}^{u} + \mathrm{e}^{-u}} \, \mathrm{d}u}_{I_2} \right)$$
Then, $$I_2= \int \frac{u \left(\mathrm{e}^{2u} - 1\right)}{\mathrm{e}^{2u} + 1} \, \mathrm{d}u\stackrel{v = \mathrm{e}^{2u} + 1}{=} \frac{1}{4} \, \int \frac{\log\left(v - 1\right) \left(v - 2\right)}{\left(v - 1\right) v} \, \mathrm{d}v$$
Decomposing this into partial fractions we have $$\frac{\log\left(v - 1\right) \left(v - 2\right)}{\left(v - 1\right) v}= \left(\frac{2 \log\left(v - 1\right)}{v} - \frac{\log\left(v - 1\right)}{v - 1}\right) $$ Therefore ,
$$I_2= 2 \int \frac{\log\left(v - 1\right)}{v} \, \mathrm{d}v - \int \frac{\log\left(v - 1\right)}{v - 1} \, \mathrm{d}v $$
Here the first integrand can be written as $$\frac{\log(v-1)}{v}=\frac{\log(1-v)}{v}+\frac{\log(-1)}{v}$$
Thus, it is equal to $$\log\left(-1\right) \log\left(v\right) - \operatorname{Li}_{2}\left(v\right) + C_2$$
The second integrand is just $$\frac{\log^{2}\left(v - 1\right)}{2} + C_3$$
Substituting these back to $I$ we get :
$$I= -\frac{\mathrm{i} \log\left(-1\right) \log\left(\left|\mathrm{e}^{2\mathrm{i}x} + 1\right|\right)}{2} - x \log\left(\left|\mathrm{e}^{\mathrm{i}x} + \mathrm{e}^{-\mathrm{i}x}\right|\right) + \log\left(\left|x\right|\right) + \frac{\mathrm{i} \operatorname{Li}_{2}\left(\mathrm{e}^{2\mathrm{i}x} + 1\right)}{2} - \frac{\mathrm{i}x^{2}}{2} + \frac{x^{2}}{2} + \log\left(2\right) \, x + C\\= \frac{-\mathrm{i} \log\left(-1\right) \log\left(\cos\left(x\right) \left|\sin\left(x\right) - \mathrm{i} \cos\left(x\right)\right|\right) + \mathrm{i} \operatorname{Li}_{2}\left(2 \cos\left(x\right) \left(\mathrm{i} \sin\left(x\right) + \cos\left(x\right)\right)\right) + \left(1 - \mathrm{i}\right) x^{2}}{2} + \log\left(\left|x\right|\right) - x \log\left(2 \cos\left(x\right)\right) + \log\left(2\right) \, x + C\\=-2\mathrm{i} \left(\frac{2\mathrm{i}x \log\left(\mathrm{e}^{2\mathrm{i}x} + 1\right) + \operatorname{Li}_{2}\left(-\mathrm{e}^{2\mathrm{i}x}\right)}{4} + \frac{x^{2}}{2}\right) - \frac{2x \log\left(\mathrm{e}^{2\mathrm{i}x} + 1\right) - 3\mathrm{i}x^{2} - 2 \log\left(2\right) \, x}{2} + \log\left(x\right) + \frac{x^{2}}{2} + C\\=-\frac{\mathrm{i} \operatorname{Li}_{2}\left(-\mathrm{e}^{2\mathrm{i}x}\right) - 2 \log\left(x\right) + \left(-\mathrm{i} - 1\right) x^{2} - 2 \log\left(2\right) \, x}{2} + C\\=(\frac12-\frac i2)x^2+x\log(1+e^{2ix})+\ln(x)-x\ln(\cos x)-\frac12 i \operatorname{Li}_2(-e^{2ix})+C$$
Here $\log(\cdot)$ is referring to the natural logarithm and $\operatorname{L1}_2(\cdot)$ is the Dilogarithm.