def error(self, text): """ Logs a non-fatal error and sets the parse status """ err_text = text if self.is_flag_set(FLAGS.DEBUG): frame = Util.get_stackframe(2) if frame: err_text = err_text + "\n @{}:{}".format( frame.f_code.co_filename, frame.f_lineno) Log.E(err_text, is_fatal=False, stackframe=3) self.status = PARSE_STATUS.ERROR
def log_error(self, msg, err_type=ERROR.BUILD, is_fatal=True, frame=Util.get_stackframe(2)): """Prints and raises an error message""" debug_info = "" local_variables = None if frame and self.has_level(LEVEL.EXTREME): f_info = inspect.getframeinfo(frame) fname = os.path.basename(f_info.filename) debug_info = "[{}@{:d}] ".format(fname, f_info.lineno) local_variables = frame.f_locals print("{}Error: {}\n".format(debug_info, msg), file=self.err_pipe) if local_variables: print("Locals:") print(local_variables) if is_fatal: raise GlobifestException(err_type, msg)
def E(msg, err_type=ERROR.BUILD, is_fatal=True, stackframe=2): """Log an error""" Logger.log_error(msg, err_type, is_fatal, Util.get_stackframe(stackframe))