def __setLevel(self, loggerName, args): if len(args) == 0: self.printHelp(u"logging") return try: level = self.__getLoggingLevelFromText(args[0]) except ValueError: print "Invalid logging level:", args[0] if loggerName is None: if level is None: print "Invalid default logging level:", args[0] return if level == logging.DEBUG: get_settings().set_logging_level(u"DEBUG") elif level == logging.INFO: get_settings().set_logging_level(u"INFO") elif level == logging.WARNING: get_settings().set_logging_level(u"WARNING") elif level == logging.ERROR: get_settings().set_logging_level(u"ERROR") elif level == logging.CRITICAL: get_settings().set_logging_level(u"CRITICAL") else: setLoggingLevel(loggerName, level)
def save_options_widget_data(self, **_kwargs): from PyQt4.QtCore import Qt from logging_level_settings.logging_level_gui import LogLevelModel get_settings().set_logging_level(self._ui.getGlobalLevelText()) model = self._ui.getModel() for row in xrange(model.rowCount()): loggerName = convert_string(model.item(row, LogLevelModel.NAME_COLUMN).data(LogLevelModel.KEY_ROLE).toString()) levelText = convert_string(model.item(row, LogLevelModel.LEVEL_COLUMN).data(Qt.DisplayRole).toString()) level = self._getLevelFromText(levelText) setLoggingLevel(loggerName, level)