Solution (source code)

= Solution

Let $\delta=1-m\downarrow0$. This is the <complete elliptic integral of the first kind> in parameter notation; the modulus used in some definitions is $\sqrt m$. Near the endpoint, $s=\pi/2-\vartheta$ gives
$$
1-m\sin^2\vartheta=\delta+s^2+O(\delta s^2+s^4).
$$
Use <matched asymptotic expansion> with an intermediate cutoff $b$ satisfying $\sqrt\delta\ll b\ll1$. Away from the endpoint the leading integral is
$$
\int_0^{\pi/2-b}\frac{d\vartheta}{\cos\vartheta}=\log\frac2b+O(b^2),
$$
while the endpoint integral is
$$
\int_0^b\frac{ds}{\sqrt{\delta+s^2}}
=\operatorname{arsinh}\frac b{\sqrt\delta}
=\log\frac{2b}{\sqrt\delta}+o(1).
$$
Adding them removes the arbitrary cutoff and gives the <logarithmic endpoint asymptotic of the complete elliptic integral>
$$
\boxed{K(m)=\log\frac4{\sqrt{1-m}}+
O\!\left((1-m)\log\frac1{1-m}\right)}.
$$
The order of the next term is therefore $(1-m)\log(1/(1-m))$, rather than merely $1-m$. More explicitly, if $L=\log(4/\sqrt\delta)$,
$$
K(m)=L+\frac\delta4(L-1)+O(\delta^2L).
$$
The logarithmic correction arises from the next terms integrated through the overlap. Its coefficient can also be found by substituting $L+\delta(aL+b)$ into the <Gauss hypergeometric equation> satisfied here, $m(1-m)K_{mm}+(1-2m)K_m-K/4=0$, giving $a=1/4$, $b=-1/4$.