1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 from __future__ import absolute_import
15 import yardstick.vTC.apexlake as apexlake
17 # Hack to be able to run apexlake unit tests
18 # without having to install apexlake.
19 sys.path.append(os.path.dirname(apexlake.__file__))
21 LOG_FILE = '/tmp/yardstick.log'
22 LOG_FORMATTER = ('%(asctime)s '
23 '%(name)s %(filename)s:%(lineno)d '
24 '%(levelname)s %(message)s')
26 _LOG_FORMATTER = logging.Formatter(LOG_FORMATTER)
27 _LOG_STREAM_HDLR = logging.StreamHandler()
28 _LOG_FILE_HDLR = logging.FileHandler(LOG_FILE)
30 LOG = logging.getLogger(__name__)
35 _LOG_STREAM_HDLR.setFormatter(_LOG_FORMATTER)
37 # don't append to log file, clobber
38 _LOG_FILE_HDLR.setFormatter(_LOG_FORMATTER)
40 del logging.root.handlers[:]
41 logging.root.addHandler(_LOG_STREAM_HDLR)
42 logging.root.addHandler(_LOG_FILE_HDLR)
43 logging.debug("logging.root.handlers = %s", logging.root.handlers)
45 if os.environ.get('CI_DEBUG', '').lower() in {'1', 1, 'y', "yes", "true"}:
46 LOG.setLevel(logging.DEBUG)
48 LOG.setLevel(logging.INFO)