def append(src, tag='Info', *args): log_items = [] for i in args: if isinstance(i, list) or isinstance(i, dict): log_items.append(object_convert.to_json(i)) elif isinstance(i, tuple) or isinstance(i, set): log_items.append(object_convert.to_json(list(i))) elif isinstance(i, int) or isinstance(i, float) or isinstance(i, str) or isinstance(i, bool) or i is None: log_items.append(i) else: log_items.append(i) log_items.append(object_convert.to_json(object_convert.object_to_dict(i))) if isinstance(src, str): source = src else: source = src.__name__ items_str = [] for item in log_items: item_str = str(item) if len(Log.replaces) > 0: for k, v in Log.replaces.items(): if k is not None: item_str = item_str.replace(k, v) items_str.append(item_str) items_str = ' '.join(items_str) with Log.lock_log: print('[%s] %s %s\n\t' % (tag, time.ctime(), source), items_str) Log.io_log.flush()
def t_event_execute(): [stat, out, err] = common.execute( path_event, env={Const.app_env: object_convert.to_json(params)}, sys_env=False, timeout=self.config.process_timeout, shell=True) Log.append( source, 'Event', { 'path': path_event, 'status': stat, 'output': out, 'error': err })