[tex]\displaystyle\int\frac{\cos x+3\sin x+7}{\cos x+\sin x+1}\,\mathrm dx=\int\mathrm dx+2\int\frac{\sin x+3}{\cos x+\sin x+1}\,\mathrm dx[/tex]
For the remaining integral, let [tex]t=\tan\dfrac x2[/tex]. Then
[tex]\sin x=\sin\left(2\times\dfrac x2\right)=2\sin\dfrac x2\cos\dfrac x2=\dfrac{2t}{1+t^2}[/tex]
[tex]\cos x=\cos\left(2\times\dfrac x2\right)=\cos^2\dfrac x2-\sin^2\dfrac x2=\dfrac{1-t^2}{1+t^2}[/tex]
and
[tex]\mathrm dt=\dfrac12\sec^2\dfrac x2\,\mathrm dx\implies \mathrm dx=2\cos^2\dfrac x2\,\mathrm dt=\dfrac2{1+t^2}\,\mathrm dt[/tex]
Now the integral is
[tex]\displaystyle\int\mathrm dx+2\int\frac{\dfrac{2t}{1+t^2}+3}{\dfrac{1-t^2}{1+t^2}+\dfrac{2t}{1+t^2}+1}\times\frac2{1+t^2}\,\mathrm dt[/tex]
The first integral is trivial, so we'll focus on the latter one. You have
[tex]\displaystyle2\int\frac{2t+3(1+t^2)}{(1-t^2+2t+1+t^2)(1+t^2)}\,\mathrm dt=2\int\frac{3t^2+2t+3}{(1+t)(1+t^2)}\,\mathrm dt[/tex]
Decompose the integrand into partial fractions:
[tex]\dfrac{3t^2+2t+3}{(1+t)(1+t^2)}=\dfrac2{1+t}+\dfrac{1+t}{1+t^2}[/tex]
so you have
[tex]\displaystyle2\int\frac{3t^2+2t+3}{(1+t)(1+t^2)}\,\mathrm dt=4\int\frac{\mathrm dt}{1+t}+2\int\frac{\mathrm dt}{1+t^2}+\int\frac{2t}{1+t^2}\,\mathrm dt[/tex]
which are all standard integrals. You end up with
[tex]\displaystyle\int\mathrm dx+4\int\frac{\mathrm dt}{1+t}+2\int\frac{\mathrm dt}{1+t^2}+\int\frac{2t}{1+t^2}\,\mathrm dt[/tex]
[tex]=x+4\ln|1+t|+2\arctan t+\ln(1+t^2)+C[/tex]
[tex]=x+4\ln\left|1+\tan\dfrac x2\right|+2\arctan\left(\arctan\dfrac x2\right)+\ln\left(1+\tan^2\dfrac x2\right)+C[/tex]
[tex]=2x+4\ln\left|1+\tan\dfrac x2\right|+\ln\left(\sec^2\dfrac x2\right)+C[/tex]
To try to get the terms to match up with the available answers, let's add and subtract [tex]\ln\left|1+\tan\dfrac x2\right|[/tex] to get
[tex]2x+5\ln\left|1+\tan\dfrac x2\right|+\ln\left(\sec^2\dfrac x2\right)-\ln\left|1+\tan\dfrac x2\right|+C[/tex]
[tex]2x+5\ln\left|1+\tan\dfrac x2\right|+\ln\left|\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}\right|+C[/tex]
which suggests A may be the answer. To make sure this is the case, show that
[tex]\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}=\sin x+\cos x+1[/tex]
You have
[tex]\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}=\dfrac1{\cos^2\dfrac x2+\sin\dfrac x2\cos\dfrac x2}[/tex]
[tex]\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}=\dfrac1{\dfrac{1+\cos x}2+\dfrac{\sin x}2}[/tex]
[tex]\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}=\dfrac2{\cos x+\sin x+1}[/tex]
So in the corresponding term of the antiderivative, you get
[tex]\ln\left|\dfrac{\sec^2\dfrac x2}{1+\tan\dfrac x2}\right|=\ln\left|\dfrac2{\cos x+\sin x+1}\right|[/tex]
[tex]=\ln2-\ln|\cos x+\sin x+1|[/tex]
The [tex]\ln2[/tex] term gets absorbed into the general constant, and so the antiderivative is indeed given by A,
[tex]\displaystyle\int\frac{\cos x+3\sin x+7}{\cos x+\sin x+1}\,\mathrm dx=2x+5\ln\left|1+\tan\dfrac x2\right|-\ln|\cos x+\sin x+1|+C[/tex]