def save_changes(self): check_expression = QtCore.QRegExp(self.rule_pattern.text()) if not check_expression.isValid(): error_message = QtWidgets.QErrorMessage(self) error_message.showMessage("Invalid regular expression: {0}".format( self.rule_pattern.text())) Logger.error("Invalid regular expression: {0}".format( self.rule_pattern.text())) return new_info_dict = {self.rule_name.text(): self.serialize_info()} self.rules_dict.update(new_info_dict) self.update_rule_list()
def load_rules(cls): if not os.path.isfile(cls.USER_RULES): shutil.copy2(cls.DEFAULT_RULES, cls.USER_RULES) # Import rules rules = None with open(cls.USER_RULES, "r") as json_file: rules = json.load(json_file) if not rules: Logger.error("User rules are empty, using defaults") with open(cls.DEFAULT_RULES, "r") as json_file: rules = json.load(json_file) rule_objects = [] for r in rules.keys(): rule_objects.append(HighlighRule.from_dict(rules[r])) return rule_objects
from ColorOut.loggingFn import Logger Logger.info("Test info") Logger.debug("Test debug") Logger.error("Test error") Logger.warning("Test warning") Logger.critical("Test critical") Logger.log(5, "Log message") # try: # a = [] # b = a[0] # except BaseException: # Logger.exception("Exception message")