scruffy/file.py
def configure(self):
        """
        Configure the Python logging module for this file.
        """
        # build a file handler for this file
        handler = logging.FileHandler(self.path, delay=True)

        # if we got a format string, create a formatter with it
        if self._format:
            handler.setFormatter(logging.Formatter(self._format))

        # if we got a string for the formatter, assume it's the name of a
        # formatter in the environment's config
        if type(self._formatter) == str:
            if self._env and self._env.config.logging.dict_config.formatters[self._formatter]:
                d = self._env.config.logging.dict_config.formatters[self._formatter].to_dict()
                handler.setFormatter(logging.Formatter(**d))
        elif type(self._formatter) == dict:
            # if it's a dict it must be the actual formatter params
            handler.setFormatter(logging.Formatter(**self._formatter))

        # add the file handler to whatever loggers were specified
        if len(self._loggers):
            for name in self._loggers:
                logging.getLogger(name).addHandler(handler)
        else:
            # none specified, just add it to the root logger
            logging.getLogger().addHandler(handler)
def configure(self):
        # build a file handler for this file
        handler = logging.FileHandler(self.path, delay=True)

        # if we got a format string, create a formatter with it
        if self._format:
            handler.setFormatter(logging.Formatter(self._format))

        # if we got a string for the formatter, assume it's the name of a
        # formatter in the environment's config
        if type(self._formatter) == str:
            if self._env and self._env.config.logging.dict_config.formatters[self._formatter]:
                d = self._env.config.logging.dict_config.formatters[self._formatter].to_dict()
                handler.setFormatter(logging.Formatter(**d))
        elif type(self._formatter) == dict:
            # if it's a dict it must be the actual formatter params
            handler.setFormatter(logging.Formatter(**self._formatter))

        # add the file handler to whatever loggers were specified
        if len(self._loggers):
            for name in self._loggers:
                logging.getLogger(name).addHandler(handler)
        else:
            # none specified, just add it to the root logger
            logging.getLogger().addHandler(handler)
def configure ( self ) : # build a file handler for this file handler = logging . FileHandler ( self . path , delay = True ) # if we got a format string, create a formatter with it if self . _format : handler . setFormatter ( logging . Formatter ( self . _format ) ) # if we got a string for the formatter, assume it's the name of a # formatter in the environment's config if type ( self . _formatter ) == str : if self . _env and self . _env . config . logging . dict_config . formatters [ self . _formatter ] : d = self . _env . config . logging . dict_config . formatters [ self . _formatter ] . to_dict ( ) handler . setFormatter ( logging . Formatter ( * * d ) ) elif type ( self . _formatter ) == dict : # if it's a dict it must be the actual formatter params handler . setFormatter ( logging . Formatter ( * * self . _formatter ) ) # add the file handler to whatever loggers were specified if len ( self . _loggers ) : for name in self . _loggers : logging . getLogger ( name ) . addHandler ( handler ) else : # none specified, just add it to the root logger logging . getLogger ( ) . addHandler ( handler )
Configure the Python logging module for this file.
Configure the Python logging module for this file .