Exemple #1
0
 def get_log_file_path(cls, template_name):
     template_name = template_name.replace(os.path.sep, "::")
     template_name = template_name.replace(".", "_")
     log_file = "{0}.log".format(template_name)
     if not cls.log_path:
         cls.log_path = ENV.get_log_dir_name()
     return os.path.join(cls.log_path, log_file)
 def test_get_log_dir_name(self):
     """Check that we get something reasonable from get_log_dir_name."""
     log_dir = ENV.get_log_dir_name()
     self.assertIsInstance(log_dir, six.string_types)
     root_parent = os.path.abspath(os.path.join(log_dir, "..", ".."))
     self.assertIsInstance(log_dir, six.string_types)
     self.assertIsNot("", log_dir)
     self.assertIsNot("/", log_dir)
     self.assertTrue(os.path.isdir(root_parent))
Exemple #3
0
 def get_logger(cls, template_name):
     """Updates the logger handler for LOG."""
     template_name = template_name.replace(os.path.sep, "::")
     template_name = template_name.replace(".", "_")
     log_file = "{0}.log".format(template_name)
     if not cls.log_path:
         cls.log_path = ENV.get_log_dir_name()
     log_file = os.path.join(cls.log_path, log_file)
     log_handle = logging.FileHandler(log_file, 'w')
     LOG = logging.getLogger()
     LOG.handlers = [log_handle]
     LOG.setLevel(logging.DEBUG)
     return LOG
Exemple #4
0
 def get_logger(cls, template_name):
     """Updates the logger handler for LOG."""
     template_name = template_name.replace(os.path.sep, "::")
     template_name = template_name.replace(".", "_")
     log_file = "{0}.log".format(template_name)
     if not cls.log_path:
         cls.log_path = ENV.get_log_dir_name()
     log_file = os.path.join(cls.log_path, log_file)
     log_handle = logging.FileHandler(log_file, 'w')
     LOG = logging.getLogger()
     LOG.handlers = [log_handle]
     LOG.setLevel(logging.DEBUG)
     return LOG
Exemple #5
0
    def setup_runtime_env(cls):
        """Sets up the environment for a current test run.

        This includes registering / parsing config options, creating the
        timestamped log directory and the results log file, if specified
        """
        # Setup logging
        cls.log_path = ENV.get_log_dir_name()
        if not os.path.isdir(cls.log_path):
            os.makedirs(cls.log_path)

        # Create results file if any, otherwise use sys.stdout
        if CONF.outfile:
            cls.output = open(CONF.outfile, "w")
        else:
            cls.output = sys.stdout
Exemple #6
0
    def setup_runtime_env(cls):
        """Sets up the environment for a current test run.

        This includes registering / parsing config options, creating the
        timestamped log directory and the results log file, if specified
        """
        # Setup logging
        cls.log_path = ENV.get_log_dir_name()
        if not os.path.isdir(cls.log_path):
            os.makedirs(cls.log_path)

        # Create results file if any, otherwise use sys.stdout
        if CONF.outfile:
            cls.output = open(CONF.outfile, "w")
        else:
            cls.output = sys.stdout
Exemple #7
0
 def setup_file_logging(cls):
     cls.log_path = ENV.get_log_dir_name()
     if not os.path.isdir(cls.log_path):
         os.makedirs(cls.log_path)