parameters: (self, component_name, domogik_prefix=True, use_filename=None, log_on_stdout=True)
docstring: Get a logger with provided parameters and set config
          @param component_name : component name to log
          @param domogik_prefix : if logger name should be prefixed by 'domogik-'
          @param use_filename : if set tells the logger to use this file name (otherwise takes 'component_name')
          @param log_on_stdout : if set to True, allow to display logs in both stdout and log file
docstring_summary: Get a logger with provided parameters and set config
docstring_tokens: Get a logger with provided parameters and set config
function: def __init__(self, component_name, domogik_prefix=True, use_filename=None, log_on_stdout=True):
          '''
          Get a logger with provided parameters and set config
          @param component_name : component name to log
          @param domogik_prefix : if logger name should be prefixed by 'domogik-'
          @param use_filename : if set tells the logger to use this file name (otherwise takes 'component_name')
          @param log_on_stdout : if set to True, allow to display logs in both stdout and log file
          '''
          if component_name not in self.logger:
              LEVELS = {
                          'debug': logging.DEBUG,
                          'info': logging.INFO,
                          'warning': logging.WARNING,
                          'error': logging.ERROR,
                          'critical': logging.CRITICAL
              }
  
              cfg = Loader()
              config = cfg.load()[0]
              if use_filename is None:
                  filename = "{0}/{1}.log".format(config['log_dir_path'], component_name)
              else:
                  filename = "{0}/{1}.log".format(config['log_dir_path'], use_filename)
              level = config['log_level']
  
              if 'log_when' not in config:
                  config['log_when'] = 'D'
              if 'log_interval' not in config:
                  config['log_interval'] = 1
              if 'log_backup_count' not in config:
                  config['log_backup_count'] = 10
  
              if level not in LEVELS:
                  raise ValueError("level must be one of 'debug','info','warning',"\
                          "'error','critical'. Check your config.")
  
              if domogik_prefix:
                  my_logger = logging.getLogger('domogik-{0}'.format(component_name))
              else:
                  my_logger = logging.getLogger(component_name)
              # log to file
              my_logger.propagate = 0
              if not my_logger.handlers:
                  hdlr = TimedRotatingFileHandler(filename, \
                          when=config['log_when'], interval=int(config['log_interval']), \
                          backupCount=int(config['log_backup_count']))
                  formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s')
                  hdlr.setFormatter(formatter)
                  my_logger.addHandler(hdlr)
  
  	        # if loglevvel is set to debug (all log entries also go to stdout)
                  if (log_on_stdout or level == 'debug') and component_name.find('sqlalchemy') == -1:
                      dhdlr = logging.StreamHandler(sys.stdout)
                      dhdlr.setFormatter(formatter)
                      my_logger.addHandler(dhdlr)
  
              my_logger.setLevel(LEVELS[level])
              self.logger[component_name] = my_logger
function_tokens: def __init__ ( self , component_name , domogik_prefix = True , use_filename = None , log_on_stdout = True ) : if component_name not in self . logger : LEVELS = { 'debug' : logging . DEBUG , 'info' : logging . INFO , 'warning' : logging . WARNING , 'error' : logging . ERROR , 'critical' : logging . CRITICAL } cfg = Loader ( ) config = cfg . load ( ) [ 0 ] if use_filename is None : filename = "{0}/{1}.log" . format ( config [ 'log_dir_path' ] , component_name ) else : filename = "{0}/{1}.log" . format ( config [ 'log_dir_path' ] , use_filename ) level = config [ 'log_level' ] if 'log_when' not in config : config [ 'log_when' ] = 'D' if 'log_interval' not in config : config [ 'log_interval' ] = 1 if 'log_backup_count' not in config : config [ 'log_backup_count' ] = 10 if level not in LEVELS : raise ValueError ( "level must be one of 'debug','info','warning'," "'error','critical'. Check your config." ) if domogik_prefix : my_logger = logging . getLogger ( 'domogik-{0}' . format ( component_name ) ) else : my_logger = logging . getLogger ( component_name ) # log to file my_logger . propagate = 0 if not my_logger . handlers : hdlr = TimedRotatingFileHandler ( filename , when = config [ 'log_when' ] , interval = int ( config [ 'log_interval' ] ) , backupCount = int ( config [ 'log_backup_count' ] ) ) formatter = logging . Formatter ( '%(asctime)s %(name)s %(levelname)s %(message)s' ) hdlr . setFormatter ( formatter ) my_logger . addHandler ( hdlr ) # if loglevvel is set to debug (all log entries also go to stdout) if ( log_on_stdout or level == 'debug' ) and component_name . find ( 'sqlalchemy' ) == - 1 : dhdlr = logging . StreamHandler ( sys . stdout ) dhdlr . setFormatter ( formatter ) my_logger . addHandler ( dhdlr ) my_logger . setLevel ( LEVELS [ level ] ) self . logger [ component_name ] = my_logger