# Path: persepolis/scripts/useful_tools.py
# def determineConfigFolder():
#     if os_type in OS.UNIX_LIKE:
#         config_folder = os.path.join(
#             home_address, ".config/persepolis_download_manager")
#     elif os_type == OS.OSX:
#         config_folder = os.path.join(
#             home_address, "Library/Application Support/persepolis_download_manager")
#     elif os_type == OS.WINDOWS:
#         config_folder = os.path.join(
#             home_address, 'AppData', 'Local', 'persepolis_download_manager')
# 
#     return config_folder
# 
# Path: persepolis/scripts/osCommands.py
# def touch(file_path):
#     if not(os.path.isfile(file_path)):
#         f = open(file_path, 'w')
#         f.close()


from persepolis.scripts.useful_tools import determineConfigFolder
from persepolis.scripts.osCommands import touch
import logging
import os
log_file = os.path.join(str(config_folder), 'persepolisdm.log')

if not os.path.isfile(log_file):
    touch(log_file)

# define logging object
logObj = logging.getLogger("Persepolis")
logObj.setLevel(logging.INFO)

# don't show log in console
logObj.propagate = False

# create a file handler
handler = logging.FileHandler(log_file)
handler.setLevel(logging.INFO)
# create a logging format
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)

# add the handlers to the logger
logObj.addHandler(handler)


def sendToLog(text="", type="INFO"):
    if type == "INFO":
        logObj.info(text)
    elif type == "ERROR":
        logObj.error(text)
    else:

# Path: persepolis/scripts/useful_tools.py
# def determineConfigFolder():
#     if os_type in OS.UNIX_LIKE:
#         config_folder = os.path.join(
#             home_address, ".config/persepolis_download_manager")
#     elif os_type == OS.OSX:
#         config_folder = os.path.join(
#             home_address, "Library/Application Support/persepolis_download_manager")
#     elif os_type == OS.WINDOWS:
#         config_folder = os.path.join(
#             home_address, 'AppData', 'Local', 'persepolis_download_manager')
# 
#     return config_folder
# 
# Path: persepolis/scripts/osCommands.py
# def touch(file_path):
#     if not(os.path.isfile(file_path)):
#         f = open(file_path, 'w')
#         f.close()


# Path: persepolis/scripts/logger.py
from persepolis.scripts.useful_tools import determineConfigFolder
from persepolis.scripts.osCommands import touch
import logging
import os

log_file = os.path.join(str(config_folder), 'persepolisdm.log')

if not os.path.isfile(log_file):
    touch(log_file)

# define logging object
logObj = logging.getLogger("Persepolis")
logObj.setLevel(logging.INFO)

# don't show log in console
logObj.propagate = False

# create a file handler
handler = logging.FileHandler(log_file)
handler.setLevel(logging.INFO)
# create a logging format
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)

# add the handlers to the logger
logObj.addHandler(handler)


def sendToLog(text="", type="INFO"):
    if type == "INFO":
        logObj.info(text)
    elif type == "ERROR":
        logObj.error(text)
    else:

        logObj.warning(text)