3 # feng.xiaowei@zte.com.cn
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 file_path = '/var/log'
30 formatter = logging.Formatter('%(asctime)s - %(name)s - '
31 '%(levelname)s - %(message)s')
33 def __init__(self, logger_name):
35 IF_DEBUG = os.getenv('IF_DEBUG')
37 self.logger_name = logger_name
38 self.logger = logging.getLogger(logger_name)
39 self.logger.propagate = 0
40 self.logger.setLevel(logging.DEBUG)
42 ch = logging.StreamHandler()
43 ch.setFormatter(self.formatter)
44 if IF_DEBUG is not None and IF_DEBUG.lower() == "true":
45 ch.setLevel(logging.DEBUG)
47 ch.setLevel(logging.INFO)
48 self.logger.addHandler(ch)
50 hdlr = logging.FileHandler('%s/%s.log' % (self.file_path, logger_name))
51 hdlr.setFormatter(self.formatter)
52 hdlr.setLevel(logging.DEBUG)
53 self.logger.addHandler(hdlr)
60 class KibanaDashboardLogger(Logger):
61 file_path = '/var/log/kibana_dashboard'
63 def __init__(self, logger_name):
64 super(KibanaDashboardLogger, self).__init__(logger_name)