By seeing example code on that page i can't observe any logical relation from output number given the input. I want to be able to understand what this function actually do.
If you have the equation x = by then y is the logarithm of x to base b. The natural logarithm just means that the base is e http://en.wikipedia.org/wiki/E_%28mathematical_constant%29
There is also a function named log10 that use base 10.
When you have an exponentiation on the form by, b is called the base and y is called the exponent. What the log functions returns is the exponent. Don't confuse the word base with how it's used when talking about numeral systems (hex, dec, etc.). They mean different things.
It's just a matter of solving the equation.
x = 10y
y = log10(x)
x = 2y
y = log2(x)
x = ey
y = log(x)
These equations are usually not easy to solve by hand so that's why we can use the functions. As you probably have noticed we don't have a log function for arbitrary bases, so it's a hard problem to solve efficiently even for a computer.