aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSridhar Rao <sridhar.rao@spirent.com>2018-08-22 14:48:47 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-08-22 14:48:47 +0000
commit01724ca5eb6198cd0d9bf804e1c7972b2b1edf09 (patch)
tree3ed06297cc44b55bf54964975db8aacdf90da420
parent65f40a88070baaa58d999cfb358a81befe6b8cc9 (diff)
parentb9f0a63e2a1d9b94f401f9fc31ff47dc739fa967 (diff)
Merge "Logging: Enhance logging with separate files and timestamps"
-rw-r--r--conf/00_common.conf5
-rwxr-xr-xvsperf24
2 files changed, 27 insertions, 2 deletions
diff --git a/conf/00_common.conf b/conf/00_common.conf
index d54c8a5a..a846fb55 100644
--- a/conf/00_common.conf
+++ b/conf/00_common.conf
@@ -98,11 +98,14 @@ SHELL_CMD = ['/bin/bash', '-c']
LOG_DIR = '/tmp'
# default log for all "small" executables
-LOG_FILE_DEFAULT = 'overall.log'
+LOG_FILE_DEFAULT = 'vsperf-overall.log'
# log file for all commands executed on host
LOG_FILE_HOST_CMDS = 'host-cmds.log'
+# log file prefix for infrastructure metrics
+LOG_FILE_INFRA_METRICS_PFX = 'collectd_'
+
# ############################
# Test configuration
# ############################
diff --git a/vsperf b/vsperf
index a1417420..5c1d88a1 100755
--- a/vsperf
+++ b/vsperf
@@ -235,13 +235,22 @@ def parse_arguments():
def configure_logging(level):
"""Configure logging.
"""
+ date = datetime.datetime.fromtimestamp(time.time())
+ timestamp = date.strftime('%Y-%m-%d_%H-%M-%S')
+ settings.setValue('LOG_TIMEMSTAMP', timestamp)
+ name, ext = os.path.splitext(settings.getValue('LOG_FILE_DEFAULT'))
+ rename_default = "{name}_{uid}{ex}".format(name=name, uid=timestamp, ex=ext)
log_file_default = os.path.join(
- settings.getValue('LOG_DIR'), settings.getValue('LOG_FILE_DEFAULT'))
+ settings.getValue('LOG_DIR'), rename_default)
log_file_host_cmds = os.path.join(
settings.getValue('LOG_DIR'), settings.getValue('LOG_FILE_HOST_CMDS'))
log_file_traffic_gen = os.path.join(
settings.getValue('LOG_DIR'),
settings.getValue('LOG_FILE_TRAFFIC_GEN'))
+ metrics_file = (settings.getValue('LOG_FILE_INFRA_METRICS_PFX') +
+ timestamp + '.log')
+ log_file_infra_metrics = os.path.join(settings.getValue('LOG_DIR'),
+ metrics_file)
_LOGGER.setLevel(logging.DEBUG)
@@ -253,6 +262,8 @@ def configure_logging(level):
file_logger = logging.FileHandler(filename=log_file_default)
file_logger.setLevel(logging.DEBUG)
+ file_logger.setFormatter(logging.Formatter(
+ '%(asctime)s : %(message)s'))
_LOGGER.addHandler(file_logger)
class CommandFilter(logging.Filter):
@@ -265,6 +276,11 @@ def configure_logging(level):
def filter(self, record):
return record.getMessage().startswith(trafficgen.CMD_PREFIX)
+ class CollectdMetricsFilter(logging.Filter):
+ """Filter out strings beginning with 'COLLECTD' :'"""
+ def filter(self, record):
+ return record.getMessage().startswith('COLLECTD')
+
cmd_logger = logging.FileHandler(filename=log_file_host_cmds)
cmd_logger.setLevel(logging.DEBUG)
cmd_logger.addFilter(CommandFilter())
@@ -275,6 +291,12 @@ def configure_logging(level):
gen_logger.addFilter(TrafficGenCommandFilter())
_LOGGER.addHandler(gen_logger)
+ if settings.getValue('COLLECTOR') == 'Collectd':
+ met_logger = logging.FileHandler(filename=log_file_infra_metrics)
+ met_logger.setLevel(logging.DEBUG)
+ met_logger.addFilter(CollectdMetricsFilter())
+ _LOGGER.addHandler(met_logger)
+
def apply_filter(tests, tc_filter):
"""Allow a subset of tests to be conveniently selected