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 RelengLogger as rl
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, level="INFO"):
31 self.logger = logging.getLogger(logger_name)
32 self.logger.propagate = 0
33 self.logger.setLevel(logging.DEBUG)
35 ch = logging.StreamHandler()
36 formatter = logging.Formatter('%(asctime)s - %(name)s - '
37 '%(levelname)s - %(message)s')
38 ch.setFormatter(formatter)
39 if level.lower() == "debug":
40 ch.setLevel(logging.DEBUG)
42 ch.setLevel(logging.INFO)
43 self.logger.addHandler(ch)
45 hdlr = logging.FileHandler('/tmp/releng.log')
46 hdlr.setFormatter(formatter)
47 hdlr.setLevel(logging.DEBUG)
48 self.logger.addHandler(hdlr)