import math


def log(x, y=None):
    """Return the logarithm of x with base y (default to e)"""
    if x <= 0:
        raise ValueError(f"Expected non-negative value. Received {x}.")
    if y is not None and y <= 0:
        raise ValueError(f"Expected non-negative value. Received {y}.")
    return math.log(x, y if y else math.e)