Say that $\{a_n\}_{n\geq 1}$, $|a_n|\leq 1$, are such that $$\left|\sum_{n\leq x} a_n \log \frac{x}{n}\right|\leq \epsilon x\quad\text{for all $x\geq x_0$.}$$ What sort of bound can we deduce on $S(x)=\sum_{n\leq x} a_n$?

*Naïve answer.*
It is easy to give a simple bound:
since, for $y>1$, $$\begin{aligned}
\left|\sum_{n\leq x y} a_n \log \frac{x y}{n}
- \sum_{n\leq x/y} a_n \log \frac{x/y}{n}
\right.&\left.
- 2 (\log y) \sum_{n\leq x} a_n\right| \\
&=
\left|\sum_{x/y < n\leq x y} a_n \log \frac{x y}{n}\right|\\
&= \left|\sum_{x/y < n\leq x y} \log \frac{x y}{n}\right|\\
&\leq \int_{x/y}^{x y} \log \frac{x y}{t} dt + \log y^2 \\
&= \left(y-\frac{1}{y}\right) x - \left(\frac{x}{y}-1\right) \log y^2,
\end{aligned}$$
we know that, for $x\geq x_0/y$, assuming $y\leq x/e$,
$$\frac{1}{x}\left|\sum_{n\leq x} a_n\right|\leq \frac{\epsilon}{2 \log y} \left(y + \frac{1}{y}\right) + \frac{y - \frac{1}{y}}{\log y} - \frac{2}{ y} +\frac{2}{x}.$$
Writing $y = \exp(\delta)$, we easily see that the leading term of the right side is $\epsilon/\delta + 2 \delta$. Hence, setting $\delta = \sqrt{\epsilon/2}$ and thus obtain that $|S(x)|$ is at most roughly $\sqrt{8 \epsilon}\cdot x$.

Now, that is not just a simple bound, but a downright simple-minded one. Can one do better?