#!/Users/brian/Projects/twitter_scraper/venv/bin/python
from discord_logging.handler import DiscordHandler
from dotenv import load_dotenv
import logging
import os

def setup_logging():
    # setup stream handler
    fmt = '[%(asctime)s] %(levelname)s:%(filename)s:%(funcName)s:%(message)s'
    datefmt = '%Y-%m-%d %H:%M:%S'
    logger_level = os.getenv('LOGGER_LEVEL')
    level = getattr(logging, logger_level.upper())
    logging.basicConfig(format=fmt, datefmt=datefmt, level=level)
    logger = logging.getLogger()
    # add discord handler
    discord_handler = DiscordHandler(
        service_name = 'data_collection',
        webhook_url = os.getenv('DISCORD_URL'),
    )
    discord_handler.setFormatter(logging.Formatter('%(message)s'))
    discord_handler.setLevel(logging.WARNING)
    logger.addHandler(discord_handler)
    logging.debug('finished')

if __name__ == '__main__':
    load_dotenv()
    setup_logging()
    logging.warning('test')
