There are two cases.
First, if it's possible for the function itself to consistently have dimensions, then there's no problem with a function having a dimensional input. Focusing just on length for simplicity, what I mean is that under a rescaling of the units of length so that the numerical value of a quantity with unit length transforms as $x \rightarrow \lambda x$, if it's possible to assign a value of $d$ so that $f(\lambda x) = \lambda^d f(x)$, then $f$ has dimensions of $({\rm length})^d$ and can be used in a dimensionally consistent way. This amounts to requiring that $f(x)$ can be written as a sum of terms where every term has the same dimension. Therefore, there is no problem having powers of dimensional quantities.
The other case is for functions which don't have a nice scaling property. Then the argument must be dimensionless. However, there are some tricks that people use implicitly, when they are being lazy.
- You can always write a dimensional value in some unit system as a dimensionless number if you divide it by an appropriate constant defining your unit system. Say $x = 10\ {\rm m}$. Since $x$ has dimensions of meters, it doesn't make sense to write $\log(x)$. However, we can define a dimensionless quantity $\hat{x} = x / {\rm 1 m}$. Then it does make sense to write $\log \hat{x}$. Now, from a theoretical point of view, $\hat{x}$ is a quantity you would essentially never expect to see arise in a calculation. However, in practice, there are cases where you do just want to take the log of some value you read off of a measuring device, and so when people write $\log (10\ {\rm m})$ this is often what they mean. Note that since $\log(x/{\rm 1\ m}) \neq \log(x/{\rm 1\ cm})$, the value of the log depends on the units in which $x$ is measured.
- Specifically for $\log$, because $\log(ab)=\log(a)+\log(b)$, using the above trick you can always split the log into two pieces that depend on the unit system, but where the unit system dependence cancels out at the end. For example, say we have $\log(x/y)$, where $x$ and $y$ are both lengths. Defining $\hat{x}$ and $\hat{y}$ as $x/{\rm 1\ m}$ and $y/{\rm 1\ m}$ as above, we can write $\log(x/y) = \log\hat{x} - \log\hat{y}$. We might then find it useful to do some manipulations involving only $\log\hat{x}$, so at intermediate stages of the calculation you have expressions that you could lazily write as $\log(10\ {\rm m})$ (if $\hat{x}=10$). Sometimes, authors don't dot the i's mathematically, and give you an expression as a final answer that is really just one of these intermediate steps that has not yet been recombined with the unit-cancelling $\log \hat{y}$ factor. Usually, you can tell from context when this is happening.