import time
import logging


def log_timing(func):
    """Decorator to time a module or function within a code.

    Parameters
    ----------
    func : func
        The function to time.

    Returns
    -------
    wrapped : func
        The wrapped function. Will log the time."""

    def wrapped(*args, **kwargs):

        # Call the function and time it
        start = time.time()
        func(*args, **kwargs)
        end = time.time()

        # Log execution time
        hours, remainder = divmod(end - start, 60 * 60)
        minutes, seconds = divmod(remainder, 60)
        logging.info('')
        logging.info('Elapsed Time of {}: {}:{}:{}'.format(func.__name__, int(hours), int(minutes), int(seconds)))

    return wrapped