import datetime
import logging
import os

from fastapi.security import OAuth2PasswordBearer

date = f'{datetime.datetime.now().year}-{datetime.datetime.now().month}-{datetime.datetime.now().day}'
logger = logging.getLogger('discord_app')

# date = f'{datetime.datetime.now().year}-{datetime.datetime.now().month}-{datetime.datetime.now().day}'
# log_level = logger.info if os.environ.get('LOG_LEVEL') == 'INFO' else 'WARN'
# logging.basicConfig(
#     filename=f'logs/database/{date}.log',
#     format='%(asctime)s - sba-database - %(levelname)s - %(message)s',
#     level=log_level
# )


oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
priv_help = False if not os.environ.get('PRIVATE_IN_SCHEMA') else os.environ.get('PRIVATE_IN_SCHEMA').upper()
PRIVATE_IN_SCHEMA = True if priv_help == 'TRUE' else False


def valid_token(token):
    return token == os.environ.get('API_TOKEN')
