Let $u=xy$. Differentiate the given function with respect to $x$:
$$
y\frac{df(u)}{du}=\frac{df(x)}{dx}+\frac{1}{xy}-\frac{x+y-1}{x^2y}
$$
Then differentiate w.r.t. $y$:
$$
xy\frac{d^2f(u)}{du^2}+\frac{df(u)}{du}=-\frac{1}{xy^2}-\frac{1}{x^2y}+\frac{x+y-1}{x^2y^2}
$$
The right-hand side simplifies:
$$
xy\frac{d^2f(u)}{du^2}+\frac{df(u)}{du}=-\frac{1}{x^2y^2}
$$
Substituting $u$ for $xy$:
$$
u\frac{d^2f(u)}{du^2}+\frac{df(u)}{du}=-\frac{1}{u^2}
$$
Re-writing the left-hand side:
$$
\frac{d}{du}\left[u\frac{df(u)}{du}\right]=-\frac{1}{u^2}
$$
Integrating and applying the given boundary condition gives:
$$
u\frac{df(u)}{du}=1+\frac{1}{u}
$$
Integrating again gives:
$$
f(u)=a+\ln{u}-\frac{1}{u}
$$
This is a solution when $a=0$, so:
$$
f(x)=\ln{x}-\frac{1}{x}
$$