import logging
import os
import inspect


log_level = os.getenv('LOG_LEVEL', 'INFO').upper()


logging.basicConfig(
    level=log_level,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)


# depricated
LOG = logging.getLogger(__name__)


def get_logger():
    caller_frame = inspect.stack()[1]
    module = inspect.getmodule(caller_frame.frame)
    module_name = module.__name__ if module else '__main__'
    return logging.getLogger(module_name)
