Log events to a file.

    Args:
        status (bool, Optional, Default=True)
            whether logging to file should be turned on(True) or off(False)
        filename (string, Optional, Default=None) :
            path of file to log to
        level (string, Optional, Default=None) :
            level of logging; whichever level is chosen all higher levels
            will be logged.
            See: https://docs.python.org/2/library/logging.html#levels

def log_to_file(status=True, filename=DEFAULT_LOG_FILE, level=None):
    """Log events to a file.

    Args:
        status (bool, Optional, Default=True)
            whether logging to file should be turned on(True) or off(False)
        filename (string, Optional, Default=None) :
            path of file to log to
        level (string, Optional, Default=None) :
            level of logging; whichever level is chosen all higher levels
            will be logged.
            See: https://docs.python.org/2/library/logging.html#levels
      """

    if status:
        if level is not None:
            LOGGER.setLevel(level)

        try:
            os.mkdir(os.path.dirname(filename))
        except OSError:
            pass

        file_handler = logging.FileHandler(filename)
        # create formatter
        fomat_str = '%(levelname)s-%(name)s: %(message)s'
        formatter = logging.Formatter(fomat_str)
        # add formatter to handler
        file_handler.setFormatter(formatter)
        LOGGER.addHandler(file_handler)

        LOGGER.info("pangaea %s", version())

    else:
        for handle in LOGGER.handlers:
            if type(handle).__name__ == 'FileHandler':
                LOGGER.removeHandler(handle)