3 # jose.lausuch@ericsson.com
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
19 # import functest_logger as fl
20 # logger = fl.Logger("script_name").getLogger()
21 # logger.info("message to be shown with - INFO - ")
22 # logger.debug("message to be shown with - DEBUG -")
29 def __init__(self, logger_name):
31 CI_DEBUG = os.getenv('CI_DEBUG')
33 self.logger = logging.getLogger(logger_name)
34 self.logger.propagate = 0
35 self.logger.setLevel(logging.DEBUG)
37 ch = logging.StreamHandler()
38 formatter = logging.Formatter('%(asctime)s - %(name)s - '
39 '%(levelname)s - %(message)s')
40 ch.setFormatter(formatter)
41 if CI_DEBUG is not None and CI_DEBUG.lower() == "true":
42 ch.setLevel(logging.DEBUG)
44 ch.setLevel(logging.INFO)
45 self.logger.addHandler(ch)
47 hdlr = logging.FileHandler('/home/opnfv/functest/results/functest.log')
48 hdlr.setFormatter(formatter)
49 hdlr.setLevel(logging.DEBUG)
50 self.logger.addHandler(hdlr)