from pathlib import Path
import logging


def create_logging_instance(log_filename):
    """
    checks if the subdir: "logs" in the current script folder exists
    if not, the subdirectory will be created and the logfile will be stored there

    Args:
        log_filename: filename of the logfile

    Returns:
    logging() object with INFO loglevel set
    """
    log_path = Path('logs/')
    if not Path.exists(log_path):
        Path.mkdir(log_path)
    log_filename_with_path = log_path / log_filename
    logging.basicConfig(filename=log_filename_with_path.as_posix(),
                        format='%(asctime)s %(message)s',
                        filemode='w')
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    return logger, log_filename_with_path