def init(self, target, file_name, file_size=100 * 1024 * 1024, max_file_count=-1, multiprocess=False): try: if multiprocess: lock = multiprocessing.RLock() else: lock = threading.RLock() if not os.path.exists(target): os.makedirs(target) if not os.path.exists(target): return False self.__process = Writer(lock, target, file_name + '.process.log', file_size, max_file_count) if not self.__process.open(): return False self.__report = Writer(lock, target, file_name + '.report.log', file_size, max_file_count) if not self.__report.open(): return False if not SysLog.open(): return False return True except: print traceback.format_exc()
def init(cls, env, target, file_name, file_size=100 * 1024 * 1024, max_file_count=-1, multiprocess=False): try: if multiprocess: lock = multiprocessing.RLock() else: lock = threading.RLock() if not os.path.exists(target): os.makedirs(target) if not os.path.exists(target): return False cls.__process = Writer(lock, target, file_name + '.process.log', file_size, max_file_count) if not cls.__process.open(): return False cls.__report = Writer(lock, target, file_name + '.report.log', file_size, max_file_count) if not cls.__report.open(): return False cls.__sep = '\x1E' cls.__env = env cls.__thread_local = threading.local() cls.__thread_local.the_id = None if not SysLog.open(): return False return True except: print traceback.format_exc()