Use the \mathop command, as in:
\newcommand{\diag}{\mathop{\rm diag}}
Subscripts and superscripts on \diag will be placed exactly as they
are on \lim. If you want your subscripts and superscripts always
placed to the right, do:
\newcommand{\diag}{\mathop{\rm diag}\nolimits}
This works in LaTeX 2.09 and in LaTeX2e, but not under NFSS alone
(see problems with \rm, etc.).
However, the canonical method for doing this in LaTeX2e is to use
the the \DeclareMathOperator command of amsopn.sty (which is
part of the AMS-LaTeX package: macros/latex/packages/amslatex).
(It should be noted that ``log-like'' was reportedly a joke on Lamport's part; it is of course clear what was meant.)