(4) If there exists an obtuse angle $\alpha$, such that $\sin \alpha-\sqrt{3} \cos \alpha=\log _{2}\left(x^{2}-x+2\right)$ holds, then the range of real number $x$ is ( ).
(A) $\{x \mid-1 \leqslant x<0$ or $1<x \leqslant 2\}$
(B) $\{x \mid-1<x<0$ or $1<x<2\}$
(C) $\{x \mid 0 \leqslant x \leqslant 1\}$
(D) $\{x \mid-1<x<2\}$
(4) Given $\frac{\pi}{2}<\alpha<\pi$, then
$$
\sin \alpha-\sqrt{3} \cos \alpha=2 \sin \left(\alpha-\frac{\pi}{3}\right) \in(1,2],
$$

it follows that
$$
1<\log _{2}\left(x^{2}-x+2\right) \leqslant 2,
$$

which means
$$
2<x^{2}-x+2 \leqslant 4,
$$

solving this yields $-1 \leqslant x<0$ or $1<x \leqslant 2$. Therefore, the answer is $\mathrm{A}$.