我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用xbmc.LOGFATAL。
def log(msg, level=xbmc.LOGNOTICE): """ Outputs message to log file :param msg: message to output :param level: debug levelxbmc. Values: xbmc.LOGDEBUG = 0 xbmc.LOGERROR = 4 xbmc.LOGFATAL = 6 xbmc.LOGINFO = 1 xbmc.LOGNONE = 7 xbmc.LOGNOTICE = 2 xbmc.LOGSEVERE = 5 xbmc.LOGWARNING = 3 """ log_message = u'{0}: {1}'.format(addonID, msg) xbmc.log(log_message.encode("utf-8"), level)
def emit(self, record): if record.levelno < logging.WARNING and self._modules and not record.name in self._modules: # Log INFO and DEBUG only with enabled modules return levels = { logging.CRITICAL: xbmc.LOGFATAL, logging.ERROR: xbmc.LOGERROR, logging.WARNING: xbmc.LOGWARNING, logging.INFO: xbmc.LOGNOTICE, logging.DEBUG: xbmc.LOGSEVERE, logging.NOTSET: xbmc.LOGNONE, } try: xbmc.log(self.format(record), levels[record.levelno]) except: try: xbmc.log(self.format(record).encode('utf-8', 'ignore'), levels[record.levelno]) except: xbmc.log(b"[%s] Unicode Error in message text" % self.pluginName, levels[record.levelno])
def log(message,loglevel=xbmc.LOGNOTICE): """"save message to kodi.log. Args: message: has to be unicode, http://wiki.xbmc.org/index.php?title=Add-on_unicode_paths#Logging loglevel: xbmc.LOGDEBUG, xbmc.LOGINFO, xbmc.LOGNOTICE, xbmc.LOGWARNING, xbmc.LOGERROR, xbmc.LOGFATAL """ xbmc.log(encode(__addon_id__ + u": " + message), level=loglevel)
def critical(self, message): message = prep_log_message(message) if xbmc: self._log(message, xbmc.LOGFATAL) else: self._log.critical(message)
def emit(self, record): levels = { logging.CRITICAL: xbmc.LOGFATAL, logging.ERROR: xbmc.LOGERROR, logging.WARNING: xbmc.LOGWARNING, logging.INFO: xbmc.LOGINFO, logging.DEBUG: xbmc.LOGDEBUG, logging.NOTSET: xbmc.LOGNONE, } if get_setting_as_bool('debug'): try: xbmc.log(self.format(record), levels[record.levelno]) except UnicodeEncodeError: xbmc.log(self.format(record).encode( 'utf-8', 'ignore'), levels[record.levelno])
def getAddonInfo(self, infoId): """ --Returns the value of an addon property as a string. infoId : string - id of the property that the module needs to access. *Note, choices are (author, changelog, description, disclaimer, fanart. icon, id, name, path profile, stars, summary, type, version) example: - version = self.Addon.getAddonInfo('version') """ infoId = infoId.lower() pathDir = xbmc.translatePath(self.addonPath) if not os.path.exists(pathDir): xbmc.log('The path ' + pathDir + 'for addon ' + self.addonId + 'dosen\'t exists', xbmc.LOGFATAL) return '' if infoId in ['changelog', 'fanart', 'icon', 'path', 'profile']: if infoId == 'changelog': return os.path.join(pathDir, 'changelog.txt') elif infoId == 'fanart': return os.path.join(pathDir, 'fanart.jpg') elif infoId == 'icon': return os.path.join(pathDir, 'icon.png') elif infoId == 'path': return pathDir elif infoId == 'profile': return 'special://profile/addon_data/' + self.addonId + '/' addonXmlFile = os.path.join(pathDir, 'addon.xml') if not os.path.exists(addonXmlFile): return None if infoId == 'author': infoId = 'provider-name' attributes = ['id', 'version', 'name', 'provider-name'] root = self._parseXml(addonXmlFile) if infoId in attributes: return root.attrib.get(infoId, None) if infoId == 'type': infoId = 'point' if infoId in ['point', 'library']: for extension in root.iter('extension'): if 'library' not in extension.attrib: continue ret = extension.attrib.get(infoId, None) break else: ret = None return ret metadata = ['summary', 'description', 'disclaimer', 'platform', 'supportedcontent', 'language', 'license', 'forum', 'website', 'source', 'email'] if infoId in metadata: metadataInfo = root.find('./extension/{}'.format(infoId)) if metadataInfo is not None: return metadataInfo.text return '' if infoId == 'requires': modList = [] for animp in root.findall('./requires/import'): modList.append(animp.attrib) return modList if infoId == 'stars': return '0'