Lebesgue measurability of $g(x)=\sup \{\frac{1}{m(B)}\int_{B}|f(y)|dy :B$ contains $x\}$

Suppose $f:\mathbb{R}\to\mathbb{R}$ is a Lebesgue integrable function, and we define $$g(x)=\sup \{\frac{1}{m(B)}\int_{B}|f(y)|dy :B\text{ is an open interval containing }x\}$$

I am asked to prove that $g(x)$ is a Lebesgue measurable function.

The only ways I know (remember?) to demonstrate measurability of a function are either to explicitly show that $g(x) < \alpha$ is a measurable set for all $\alpha \in \mathbb{R}$, or to express $g(x)$ as a sum, sup over sequence, limit over sequence, etc. of measurable functions or almost everywhere equal to one.

I don't see how to try to show the preimages are measurable sets, and anyway my guess is that I want to express this $g$ as a sup. I can cut down the amount of intervals under consideration by restricting without loss of generality to intervals with rational endpoints, which seems relevant if I want a countable sequence of things to take the sup over.

My current strategy is to at each point x enumerate the set $I_x$ intervals around x which have rational endpoints, so that $I_x = \{I_{x,n}\}_{n\in\mathbb{N}}$, and then let $$g_n (x)= \frac{1}{m(I_{x,n})}\int_{I_{x,n}}|f(y)|dy$$ This gives me $g(x) = \sup g_n (x)$

However, I don't see that each $g_n$ is measurable, and I haven't yet made use of the integrability of $f$ (these are probably related).

The farthest I've gone to that end is that $$\{x: g_n(x)<\alpha\} = \{x: \int_{I_{x,n}}|f(y)|dy < \alpha m(I_{x,n})\}$$ which suggests to me that the measurability of $g_n$ should follow from measurability of the integral above as a sort of function of the domain of integration. However, I'm not sure how to check that.

So, sanity check: does this make sense so far? Have I overlooked something simple at the end there? Are there better ways to go about this? Any hints or comments are welcome.

(As reassurance, though you don't have to believe me, I'm studying, not doing an assignment. So I'm more interested in getting a better sense of what's going on and being prepared for similar questions, rather than getting this one in particular.)

-
Hint: enumerate all the open intervals with rational endpoints, without regard to $x$: say $\{I_n\}$. Now let $g_n(x) = \frac{1}{m(I_n)} \int_{I_n} |f(t)|\, dt$ if $x$ is in $I_n$, 0 otherwise.