Estimating a quantity from an estimate in its integral

I am reading a paper in which the following argument is made. We have two positive real valued functions $f(x)$ and $g(x)$. We know that $$\int_0^x \int_0^y f(z) \ dz \ dy \leq g(x).$$

It is then stated "and easy computation shows that, except for negligibly small intervals," $$\log f(x) = O(x + \log g(x)).$$

I am at a loss on how this comes about. $g(x)$ is convex, if that helps. Can anyone explain?

-

We begin with a lemma. Let $F$ be an increasing function tending to infty as $x\to\infty$. Then $F'(x)\leq F^2(x)$, for $x\not\in E$, where $E$ is a set of finite measure.
Proof. Let $E$ be the set where $F'(x)\geq F^2(x)$. Then $$|E|\leq\int_{E\cap[1,\infty)}\frac{F'}{F^2}dx<\int_1^\infty\frac{F'}{F^2}dx<\infty,$$ by the change of the variable $y=F(x)$.
Now your conditions imply that $g(x)\to\infty$; $g$ and $g'$ are increasing.
Suppose first that $g'(x)\to\infty$. Your relation between $g$ and $f$ means that $g^{\prime\prime}=f$. Applying the lemma first to $g$, and then to $g'$, we obtain the result $\log f(x)=O(\log g(x))$. The case when $g'$ is bounded I leave as an exercise.