\int \frac{cosx+1-sinx}{cosx-1+sinx} = \int \frac{1-tan^{2}\frac{x}{2} + 1 +tan^{2}\frac{x}{2} - 2 tan\frac{x}{2}}{1-tan^{2}\frac{x}{2} - 1 -tan^{2}\frac{x}{2} + 2 tan\frac{x}{2}} = \int cot\frac{x}{2}dx
\int cot\frac{x}{2}dx = log\left|sin^{2}\frac{x}{2} \right|