import logging


def set_up_logger(name, file_path, level=logging.INFO, verbose=True):
    """
    Creates basic logger object that optionally also logs to command-line.
    :param name: (string) Name of the logger. Should be called with __name__.
    :param file_path: (string) File location of the output handler.
    :param level: (logging.LEVEL) Specifies the logging level which is output.
    :param verbose: (boolean) If set to True, will also log with the appropriate level to stdout.
    :return: logging.Logger object with the specified properties.
    """

    # create base logger
    logger = logging.getLogger(name)
    logger.setLevel(level)

    # format the date accordingly
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s \t: %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')

    # add handler for write to file
    fh = logging.FileHandler(file_path)
    fh.setLevel(level)
    fh.setFormatter(formatter)
    logger.addHandler(fh)

    # add handler for stream output if wanted
    if verbose:
        sh = logging.StreamHandler()
        sh.setLevel(level)
        sh.setFormatter(formatter)
        logger.addHandler(sh)

    return logger