def setup_log(self): # TODO: use bt.utils.loggers.get_logger import logging as logging_mod if not os.path.exists(self.log_folder): os.makedirs(self.log_folder) self.logfile = os.path.join( self.log_folder, 'build_%s_%s.log' % (self.build_name, time.strftime("%Y%m%d", self.timestamp.timetuple()))) fh = logging_mod.FileHandler(self.logfile) fmt = logging_mod.Formatter( '%(asctime)s [%(process)d:%(threadName)s] - %(name)s - %(levelname)s -- %(message)s', datefmt="%H:%M:%S") fh.setFormatter(fmt) fh.name = "logfile" nh = HipchatHandler(btconfig.HIPCHAT_CONFIG) nh.setFormatter(fmt) nh.name = "hipchat" self.logger = logging_mod.getLogger("%s_build" % self.build_name) self.logger.setLevel(logging_mod.DEBUG) if not fh.name in [h.name for h in self.logger.handlers]: self.logger.addHandler(fh) if not nh.name in [h.name for h in self.logger.handlers]: self.logger.addHandler(nh) return self.logger
def setup_log(self): """Setup and return a logger instance""" import logging as logging_mod if not os.path.exists(self.src_root_folder): os.makedirs(self.src_root_folder) self.logfile = os.path.join(self.log_folder, 'upload_%s_%s.log' % (self.fullname,time.strftime("%Y%m%d",self.timestamp.timetuple()))) fmt = logging_mod.Formatter('%(asctime)s [%(process)d:%(threadName)s] - %(name)s - %(levelname)s -- %(message)s', datefmt="%H:%M:%S") fh = logging_mod.FileHandler(self.logfile) fh.setFormatter(fmt) fh.name = "logfile" nh = HipchatHandler(config.HIPCHAT_CONFIG) nh.setFormatter(fmt) nh.name = "hipchat" logger = logging_mod.getLogger("%s_upload" % self.fullname) logger.setLevel(logging_mod.DEBUG) if not fh.name in [h.name for h in logger.handlers]: logger.addHandler(fh) if not nh.name in [h.name for h in logger.handlers]: logger.addHandler(nh) return logger
def setup_log(self): import logging as logging_mod if not os.path.exists(self.src_root_folder): os.makedirs(self.src_root_folder) self.logfile = os.path.join( self.log_folder, 'dump_%s_%s.log' % (self.src_name, self.timestamp)) fmt = logging_mod.Formatter( '%(asctime)s [%(process)d:%(threadName)s] - %(name)s - %(levelname)s -- %(message)s', datefmt="%H:%M:%S") fh = logging_mod.FileHandler(self.logfile) fh.setFormatter(fmt) fh.name = "logfile" nh = HipchatHandler(HIPCHAT_CONFIG) nh.setFormatter(fmt) nh.name = "hipchat" self.logger = logging_mod.getLogger("%s_dump" % self.src_name) self.logger.setLevel(logging_mod.DEBUG) if not fh.name in [h.name for h in self.logger.handlers]: self.logger.addHandler(fh) if not nh.name in [h.name for h in self.logger.handlers]: self.logger.addHandler(nh) return self.logger