示例#1
0
    def test_configure_by_file(self):
        """Testing function Logger.configure_default."""
        logging_config_filename = "logging.conf"

        with patch('logging.config.fileConfig'
                   ) as mocked_logging_config_fileConfig:
            Logger.configure_by_file(logging_config_filename)
            mocked_logging_config_fileConfig.assert_called_with(
                logging_config_filename)
            assert_that(Logger.use_external_configuration, equal_to(True))
            Logger.use_external_configuration = False
示例#2
0
    def setup_logging(self):
        """Setup of application logging."""
        is_custom_logging = len(self.options.logging_config) > 0
        is_custom_logging = is_custom_logging and os.path.isfile(
            self.options.logging_config)
        is_custom_logging = is_custom_logging and not self.options.dry_run

        if is_custom_logging:
            Logger.configure_by_file(self.options.logging_config)
        else:
            logging_format = "%(asctime)-15s - %(name)s - %(message)s"
            if self.options.dry_run:
                logging_format = "%(name)s - %(message)s"
            Logger.configure_default(logging_format, self.logging_level)