From 6183cefebbc1af8ad1987dc61372d6c2d6a59f6d Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Tue, 20 Sep 2016 13:58:21 +0800 Subject: add unified logger process for qtip log the output information to both file and console, and unify the log file path and level JIRA: QTIP-108 Change-Id: I3a881e9da1f74c6959250a94f05cf90a231c34e6 Signed-off-by: SerenaFeng --- func/env_setup.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'func/env_setup.py') diff --git a/func/env_setup.py b/func/env_setup.py index 96f984cb..cd82f303 100644 --- a/func/env_setup.py +++ b/func/env_setup.py @@ -8,18 +8,19 @@ ############################################################################## import os +import random +import socket import sys -from collections import defaultdict -import yaml import time -import paramiko -import socket +from collections import defaultdict from os.path import expanduser -import random -import logging -LOG = logging.getLogger(__name__) -LOG.setLevel(logging.DEBUG) +import paramiko +import yaml + +from utils import logger_utils + +logger = logger_utils.QtipLogger('env_setup').get class Env_setup: @@ -100,7 +101,7 @@ class Env_setup: @staticmethod def fetch_compute_ips(): - LOG.info("Fetch compute ips through installer") + logger.info("Fetch compute ips through installer") ips = [] installer_type = str(os.environ['INSTALLER_TYPE'].lower()) @@ -112,18 +113,18 @@ class Env_setup: cmd = "bash ./func/fetch_compute_ips.sh -i %s -a %s" % \ (installer_type, installer_ip) - LOG.info(cmd) + logger.info(cmd) os.system(cmd) home = expanduser("~") with open(home + "/ips.log", "r") as file: data = file.read() if data: ips.extend(data.rstrip('\n').split('\n')) - LOG.info("All compute ips: %s" % ips) + logger.info("All compute ips: %s" % ips) return ips def check_machine_ips(self, host_tag): - LOG.info("Check machine ips") + logger.info("Check machine ips") ips = self.fetch_compute_ips() ips_num = len(ips) num = len(host_tag) @@ -137,7 +138,7 @@ class Env_setup: if host_tag[hostlabel]['ip'] in ips: info = "%s's ip %s is defined by test case yaml file" % \ (hostlabel, host_tag[hostlabel]['ip']) - LOG.info(info) + logger.info(info) else: err = "%s is not in %s" % (host_tag[hostlabel]['ip'], ips) raise RuntimeError(err) -- cgit 1.2.3-korg