Step 1: Put \(x=\frac{\pi}{2}+h\).
As
\[
x\to \frac{\pi}{2},
\]
we have
\[
h\to 0
\]
Now,
\[
\sin x=\sin\left(\frac{\pi}{2}+h\right)=\cos h
\]
Also,
\[
\pi^2-4\pi x+4x^2=(2x-\pi)^2
\]
Since
\[
x=\frac{\pi}{2}+h,
\]
we get
\[
2x-\pi=2h
\]
Therefore,
\[
(2x-\pi)^2=4h^2
\]
Step 2: Rewrite the limit.
\[
f\left(\frac{\pi}{2}\right)
=
\lim_{h\to 0}
\frac{1-\cos h}{\log(1+4h^2)}
\]
Step 3: Use standard approximations.
As \(h\to 0\),
\[
1-\cos h\sim \frac{h^2}{2}
\]
Also,
\[
\log(1+4h^2)\sim 4h^2
\]
Therefore,
\[
\lim_{h\to 0}
\frac{1-\cos h}{\log(1+4h^2)}
=
\frac{\frac{h^2}{2}}{4h^2}
\]
\[
=
\frac{1}{8}
\]
Step 4: Final conclusion.
Hence,
\[
\boxed{\frac{1}{8}}
\]