"""
Manages logging throughout the Rookeries API.

:copyright: Copyright 2013-2017, Dorian Pula <dorian.pula@amber-penguin-software.ca>
:license: AGPL v3+
"""

import logging.config


def setup_logging_with_level(level='INFO'):
    return {
        'version': 1,
        'formatters': {
            'simple': {
                'format':
                    '%(asctime)s - [%(levelname)s] - %(name)s - %(message)s'
            },
        },

        'handlers': {
            'console': {
                'class': 'logging.StreamHandler',
                'level': level,
                'formatter': 'simple',
                'stream': 'ext://sys.stdout',
            }
        },

        'root': {
            'level': level,
            'handlers': ['console'],
            'propagate': False
        },

        'disable_existing_loggers': False,
    }


def configure_logging(level='INFO'):
    logging.config.dictConfig(setup_logging_with_level(level))
