##
# @file   __init__.py
# @brief  
#
# @copyright 
#
# @addtogroup 
# @{

import logging

import constants
import log_support


class Singleton(type):
    def __init__(cls, name, bases, dict):
        super(Singleton, cls).__init__(name, bases, dict)
        cls.instance = None


    def __call__(cls, *args, **kw):
        if cls.instance is None:
            cls.instance = super(Singleton, cls).__call__(*args, **kw)
        return cls.instance


# a default config of the logging subsystem
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

if not logger.handlers:
    # create a console handler
    ch = log_support.ColoredStreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(logging.Formatter(constants.LOG_FORMAT_CONSOLE))
    logger.addHandler(ch)

# level settings of specific modules
# ~ log = logging.getLogger('CommInterface')
# ~ log.setLevel(logging.DEBUG)

# @}
