generic logarithm function