$$
\begin{align}
&\lim_{n\to\infty}\int_{1/n}^n\frac{\frac12-\cos(x)}x\,\mathrm{d}x\\
&=\lim_{n\to\infty}\left(\log(n)-\int_{1/n}^1\frac{\cos(x)}x\,\mathrm{d}x-\int_1^n\frac{\cos(x)}x\,\mathrm{d}x\right)\tag{1a}\\
&=\int_0^1\frac{1-\cos(x)}x\,\mathrm{d}x-\int_1^\infty\frac{\cos(x)}x\,\mathrm{d}x\tag{1b}\\
&=\int_0^1(1-\cos(x))\,\mathrm{d}\log(x)-\lim_{n\to\infty}\int_1^{(2n+1)\pi/2}\cos(x)\,\mathrm{d}\log(x)\tag{1c}\\
&=-\int_0^1\log(x)\sin(x)\,\mathrm{d}x-\lim_{n\to\infty}\int_1^{(2n+1)\pi/2}\log(x)\sin(x)\,\mathrm{d}x\tag{1d}\\
&=-\lim_{n\to\infty}\int_0^{(2n+1)\pi/2}\log(x)\sin(x)\,\mathrm{d}x\tag{1e}\\
&=-\frac1{2i}\lim_{n\to\infty}\left(\int_0^{(2n+1)\pi/2}\log(x)\,e^{ix}\,\mathrm{d}x-\int_0^{(2n+1)\pi/2}\log(x)\,e^{-ix}\,\mathrm{d}x\right)\tag{1f}\\
&=-\frac1{2i}\lim_{n\to\infty}\left(i\int_0^{\left(n+\frac12\right)\pi}\!\!\left(\log(x){+}\tfrac{i\pi}2\right)e^{-x}\,\mathrm{d}x+i\int_0^{\left(n+\frac12\right)\pi}\!\!\left(\log(x){-}\tfrac{i\pi}2\right)e^{-x}\,\mathrm{d}x\right)\tag{1g}\\
&=-\int_0^\infty\log(x)\,e^{-x}\,\mathrm{d}x\tag{1h}\\[6pt]
&=\gamma\tag{1i}
\end{align}
$$
Explanation:
$\text{(1a)}$: break up the integral into pieces
$\text{(1b)}$: reassemble the pieces and evalate the limit
$\text{(1c)}$: write the right hand integral as a limit
$\phantom{\text{(1c):}}$ prepare to integrate by parts
$\text{(1d)}$: integrate by parts
$\text{(1e)}$: combine the integrals
$\text{(1f)}$: $\sin(x)=\frac{e^{ix}-e^{-ix}}{2i}$
$\text{(1g)}$: Cauchy's Integral Theorem
$\text{(1h)}$: evaluate the limits and combine the integrals
$\text{(1i)}$: apply this answer
Contour Integration for $\bf{(1g)}$
$\newcommand{\Re}{\operatorname{Re}}\newcommand{\Im}{\operatorname{Im}}$
Step $\text{(1g)}$ above looks like one that is often encountered in contour integration, where the integrand along the "arc at infinity" vanishes sufficiently in absolute value. However, the absolute value of the integrands along both of the arcs at infinity grows like $\log(\Re(z))e^{-|\!\Im(z)|}$. Fortunately, they have opposite signs and cancel to within an error of $O\!\left(\frac1n\right)$. This has the same effect as if the absolute value of the integrand had vanished sufficiently.

Integrating around the upper-right quadrant, we get the integral along the positive real axis by substituting $z=x$ and the integral along the positive imaginary axis by substituting $z=ix$.
The integral along the arc is a bit more complicated. As the integrand dies away like $e^{-y}$ as $y\to\infty$, we will compute the integral along $\left(n+\frac12\right)\pi+iy$, giving an error of $O\!\left(e^{-x}\right)$.
$$
\begin{align}
\frac1{2i}\int_{\left(n+\frac12\right)\pi}^{\left(n+\frac12\right)\pi+i\infty}\log(z)\,e^{iz}\,\mathrm{d}z
&=\frac1{2}\int_0^\infty(\log(x)+\log(1+iy/x))\,e^{ix-y}\,\mathrm{d}y\tag{2a}\\
&=\frac{i}2(-1)^n\int_0^\infty\left(\log(x)+O(y/x)\right)e^{-y}\,\mathrm{d}y\tag{2b}\\[3pt]
&=\frac{i}2(-1)^n\log\left(\left(n+\tfrac12\right)\pi\right)+O\!\left(\frac1n\right)\tag{2c}
\end{align}
$$
Explanation:
$\text{(2a)}$: use $z=x+iy$ where $x=\left(n+\frac12\right)\pi$
$\text{(2b)}$: $\log(1+iy/x)=O(y/x)$
$\text{(2c)}$: evaluate the integral
Integrating around the lower-right quadrant, we get the integral along the positive real axis by substituting $z=x$ and the integral along the negative imaginary axis by substituting $z=-ix$.
As the integrand dies away like $e^{-y}$ as $-y\to-\infty$, we will compute the integral along $\left(n+\frac12\right)\pi-iy$, giving an error of $O\!\left(e^{-x}\right)$.
$$
\begin{align}
-\frac1{2i}\int_{\left(n+\frac12\right)\pi}^{\left(n+\frac12\right)\pi-i\infty}\log(z)\,e^{-iz}\,\mathrm{d}z
&=\frac1{2}\int_0^\infty(\log(x)+\log(1-iy/x))\,e^{-ix-y}\,\mathrm{d}y\tag{3a}\\
&=-\frac{i}2(-1)^n\int_0^\infty\left(\log(x)+O(y/x)\right)e^{-y}\,\mathrm{d}y\tag{3b}\\[3pt]
&=-\frac{i}2(-1)^n\log\left(\left(n+\tfrac12\right)\pi\right)+O\!\left(\frac1n\right)\tag{3c}
\end{align}
$$
Explanation:
$\text{(3a)}$: use $z=x-iy$ where $x=\left(n+\frac12\right)\pi$
$\text{(3b)}$: $\log(1-iy/x)=O(y/x)$
$\text{(3c)}$: evaluate the integral
Thus, the sum of the integral along both arcs is $O\!\left(\frac1n\right)\to0$.