__version__ = "1.0.0"

# --- package ---
# --- log ---
import logging

# --- common ---
from datetime import datetime
import os
from pathlib import Path
import sys

def logger():
    if not os.path.isdir(log_path):
        os.makedirs(log_path)
    # return log instance
    logger = logging.getLogger('logger')

    exec_nm = Path(os.path.basename(sys.argv[0])).stem
    log_date = datetime.strftime('%y%m%d_%H%M%S')

    # define log format
    formatter = logging.Formatter('%(asctime)s-%(levelname)s-%(message)s')

    # define handler
    stream_handler = logging.StreamHandler()
    file_handler = logging.FileHandler(f"{log_path}{exec_nm}_{log_date}.log")

    # define handler format
    stream_handler.setFormatter(formatter)
    file_handler.setFormatter(formatter)

    # insert handler into logger instance
    logger.addHandler(stream_handler)
    logger.addHandler(file_handler)

    # define log level
    logger.setLevel(level=logging.INFO)

    # return logger
    return logger

# --- path_variables ---
loc_path = os.getcwd()
log_path = f"{loc_path}/log/"

# --- common_variables ---
datetime = datetime.now()