The OP stated at the end of the posted question
Now let's consider the function $f(z) = \frac{\log^2 z}{z^p (z-1)}$. Then we can use Cauchy theorem and residuals.
Rather than analyze a contour integral of $f(z)=\frac{\log^2 z}{z^p (z-1)}$, we analyze the integral
$$I(p)=\oint_C \frac{\log(z)}{z^p(z-1)}\,dz$$
where $C$ is the classical keyhole contour where the branch cut for $\log(z)$ is take along the positive real axis and $\arg(z)\in [0,2\pi)$. Inasmuch as $\frac{\log(z)}{z^p(z-1)}$ is analytic in and on $C$, Cauchy's Integral Theorem guarantees that
$$\begin{align}
0&=\oint_C \frac{\log(z)}{z^p(z-1)}\,dz\\\\
&=\int_\epsilon^R \frac{\log(x)}{x^p(x-1)}\,dx+\underbrace{\int_0^{2\pi }\frac{\log(Re^{i\phi})}{R^pe^{ip\phi}(Re^{i\phi}-1)}\,iRe^{i\phi}\,d\phi}_{\to 0\,\,\text{as}\,\,R\to \infty}+\int_R^{1+\nu}\frac{\log(x)+i2\pi}{x^pe^{i2\pi p}(x-1)}\,dx\\\\
&+\underbrace{\int_{2\pi}^\pi \frac{\log(1+\nu e^{i\phi})}{(1+\nu e^{i\phi})^p\nu e^{i\phi}}\,i\nu e^{i\phi}\,d\phi}_{\to -i\pi (i2\pi )e^{-i2\pi p}\,\,\text{as}\,\,\nu\to0}+\int_{1-\nu}^\epsilon \frac{\log(x)+i2\pi}{x^pe^{i2\pi p}(x-1)}\,dx+\underbrace{\int_{2\pi}^0 \frac{\log(\epsilon e^{i\phi})}{(\epsilon e^{i\phi})^p(\epsilon e^{i\phi}-1)}\,i\epsilon e^{i\phi}\,d\phi}_{\to 0\,\,\text{as}\,\,\epsilon\to 0}\tag1
\end{align}$$
Letting $\epsilon\to 0^+$, $R\to \infty$, and $\nu \to 0^+$ in $(1)$, we obtain
$$(1-e^{-i2\pi p})\int_0^\infty \frac{\log(x)}{x^p(x-1)}\,dx=i2\pi e^{-i2\pi p}\,\,\text{PV}\left(\int_0^\infty \frac{1}{x^p(x-1)}\,dx\right)+(i\pi)\left(i2\pi e^{-i2\pi p} \right)\tag2$$
where $\text{PV}\left(\int_0^\infty \frac{1}{x^p(x-1)}\,dx+i\pi\right)$ denotes the Cauchy Principal Value (CPV) integral.
We can evaluate the CVP integral as follows.
$$\begin{align}
\text{PV}\int_0^\infty \frac{1}{x^p(x-1)}\,dx&=\lim_{\nu\to 0^+}\left(\int_0^{1-\nu}\frac{1}{x^p(x-1)}\,dx+\int_{1+\nu}^\infty\frac{1}{x^p(x-1)}\,dx\right)\\\\
&=\lim_{\nu\to 0^+}\left(-\sum_{n=0}^\infty\int_0^{1-\nu}x^{n-p}\,dx+\sum_{n=0}^\infty\int_{1+\nu}^\infty x^{-n-p-1}\,dx\right)\\\\
&=\sum_{n=0}^\infty \left(\frac1{n+p}-\frac1{n-p+1}\right)\tag3
\end{align}$$
The series on the right-hand side of $(3)$ is the partial fraction representation of $\pi \cot(\pi p)$ for $p\in (0,1)$ (SEE HERE).
Substituting $(3)$ into $(2)$, dividing both sides by $(1-e^{-i2\pi p})$, we find
$$\int_0^\infty \frac{\log(x)}{x^p(x-1)}\,dx=\frac{\pi^2}{\sin^2(\pi p)}$$