Project: datamanagement
Issue DM-2272: Unify logging strategy for python scripts
- add -vvv option - remove default value for configuration file in logger, provide it at each script level (i.e. integration test, data loader). - if it exists, provide configuration file option explicitly to all called submodules which uses it. See admin/python/lsst/qserv/admin/logger.py {code:python} 14 def get_default_log_conf(): 15 default_log_conf = "{0}/.lsst/logging.ini".format(os.path.expanduser('~')) 16 return default_log_conf 17 18 def add_logfile_opt(parser): 19 """ 20 Add option to command line interface in order to set path to standar 21 configuration file for python logger 22 """ 23 24 parser.add_argument("-V", "--log-cfg", dest="log_conf", 25 default=get_default_log_conf(), 26 help="Absolute path to yaml file containing python" + 27 "logger standard configuration file") 28 return parser 29 30 31 def setup_logging(path='logging.ini', 32 default_level=logging.INFO): 33 """ 34 Setup logging configuration from yaml file 35 if the yaml file doesn't exists: 36 - return false 37 - configure logging to default_level 38 """ 39 if os.path.exists(path): 40 with open(path, 'r') as f: 41 logging.config.fileConfig(f) 42 return True 43 else: 44 logging.basicConfig(level=default_level) 45 return False {code}
Story points: 6