Logger messages (#818)
* Change the way logger messages are generated by using the printf-like method * Use single quotes around log values that can be empty strings * Fix bug in log message
This commit is contained in:
committed by
GitHub
parent
671888b6ea
commit
1b89d0a4f0
+40
-40
@@ -134,8 +134,8 @@ class GuiTheme:
|
||||
self.guiDPI = qApp.primaryScreen().logicalDotsPerInchX()
|
||||
self.guiScale = qApp.primaryScreen().logicalDotsPerInchX()/96.0
|
||||
self.mainConf.guiScale = self.guiScale
|
||||
logger.verbose("GUI DPI: %.1f" % self.guiDPI)
|
||||
logger.verbose("GUI Scale: %.2f" % self.guiScale)
|
||||
logger.verbose("GUI DPI: %.1f", self.guiDPI)
|
||||
logger.verbose("GUI Scale: %.2f", self.guiScale)
|
||||
|
||||
# Fonts
|
||||
self.guiFont = qApp.font()
|
||||
@@ -152,12 +152,12 @@ class GuiTheme:
|
||||
self.guiFontFixed.setPointSizeF(0.95*self.fontPointSize)
|
||||
self.guiFontFixed.setFamily(QFontDatabase.systemFont(QFontDatabase.FixedFont).family())
|
||||
|
||||
logger.verbose("GUI Font Family: %s" % self.guiFont.family())
|
||||
logger.verbose("GUI Font Point Size: %.2f" % self.fontPointSize)
|
||||
logger.verbose("GUI Font Pixel Size: %d" % self.fontPixelSize)
|
||||
logger.verbose("GUI Base Icon Size: %d" % self.baseIconSize)
|
||||
logger.verbose("Text 'N' Height: %d" % self.textNHeight)
|
||||
logger.verbose("Text 'N' Width: %d" % self.textNWidth)
|
||||
logger.verbose("GUI Font Family: %s", self.guiFont.family())
|
||||
logger.verbose("GUI Font Point Size: %.2f", self.fontPointSize)
|
||||
logger.verbose("GUI Font Pixel Size: %d", self.fontPixelSize)
|
||||
logger.verbose("GUI Base Icon Size: %d", self.baseIconSize)
|
||||
logger.verbose("Text 'N' Height: %d", self.textNHeight)
|
||||
logger.verbose("Text 'N' Width: %d", self.textNWidth)
|
||||
|
||||
# Internal Mapping
|
||||
self.makeAlert = self.theParent.makeAlert
|
||||
@@ -192,7 +192,7 @@ class GuiTheme:
|
||||
for fontFam in os.listdir(fontAssets):
|
||||
fontDir = os.path.join(fontAssets, fontFam)
|
||||
if os.path.isdir(fontDir):
|
||||
logger.verbose("Found font: %s" % fontFam)
|
||||
logger.verbose("Found font: %s", fontFam)
|
||||
if fontFam not in self.guiFontDB.families():
|
||||
for fontFile in os.listdir(fontDir):
|
||||
ttfFile = os.path.join(fontDir, fontFile)
|
||||
@@ -201,10 +201,10 @@ class GuiTheme:
|
||||
|
||||
for ttfFile in ttfList:
|
||||
relPath = os.path.relpath(ttfFile, fontAssets)
|
||||
logger.verbose("Adding font: %s" % relPath)
|
||||
logger.verbose("Adding font: %s", relPath)
|
||||
fontID = self.guiFontDB.addApplicationFont(ttfFile)
|
||||
if fontID < 0:
|
||||
logger.error("Failed to add font: %s" % relPath)
|
||||
logger.error("Failed to add font: %s", relPath)
|
||||
|
||||
return
|
||||
|
||||
@@ -266,7 +266,7 @@ class GuiTheme:
|
||||
"""Load the currently specified GUI theme.
|
||||
"""
|
||||
logger.debug("Loading theme files")
|
||||
logger.debug("System icon theme is '%s'" % str(QIcon.themeName()))
|
||||
logger.debug("System icon theme is '%s'", str(QIcon.themeName()))
|
||||
|
||||
# CSS File
|
||||
cssData = ""
|
||||
@@ -285,7 +285,7 @@ class GuiTheme:
|
||||
with open(self.confFile, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
except Exception:
|
||||
logger.error("Could not load theme settings from: %s" % self.confFile)
|
||||
logger.error("Could not load theme settings from: %s", self.confFile)
|
||||
nw.logException()
|
||||
return False
|
||||
|
||||
@@ -329,7 +329,7 @@ class GuiTheme:
|
||||
qApp.setStyleSheet(cssData)
|
||||
qApp.setPalette(self.guiPalette)
|
||||
|
||||
logger.info("Loaded theme '%s'" % self.guiTheme)
|
||||
logger.info("Loaded theme '%s'", self.guiTheme)
|
||||
|
||||
return True
|
||||
|
||||
@@ -343,7 +343,7 @@ class GuiTheme:
|
||||
with open(self.syntaxFile, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
except Exception:
|
||||
logger.error("Could not load syntax colours from: %s" % self.syntaxFile)
|
||||
logger.error("Could not load syntax colours from: %s", self.syntaxFile)
|
||||
nw.logException()
|
||||
return False
|
||||
|
||||
@@ -378,7 +378,7 @@ class GuiTheme:
|
||||
self.colRepTag = self._loadColour(confParser, cnfSec, "replacetag")
|
||||
self.colMod = self._loadColour(confParser, cnfSec, "modifier")
|
||||
|
||||
logger.info("Loaded syntax theme '%s'" % self.guiSyntax)
|
||||
logger.info("Loaded syntax theme '%s'", self.guiSyntax)
|
||||
|
||||
return True
|
||||
|
||||
@@ -393,7 +393,7 @@ class GuiTheme:
|
||||
themeConf = os.path.join(
|
||||
self.mainConf.themeRoot, self.guiPath, themeDir, self.confName
|
||||
)
|
||||
logger.verbose("Checking theme config for '%s'" % themeDir)
|
||||
logger.verbose("Checking theme config for '%s'", themeDir)
|
||||
try:
|
||||
with open(themeConf, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
@@ -406,7 +406,7 @@ class GuiTheme:
|
||||
if confParser.has_section("Main"):
|
||||
if confParser.has_option("Main", "name"):
|
||||
themeName = confParser.get("Main", "name")
|
||||
logger.verbose("Theme name is '%s'" % themeName)
|
||||
logger.verbose("Theme name is '%s'", themeName)
|
||||
if themeName != "":
|
||||
self.themeList.append((themeDir, themeName))
|
||||
|
||||
@@ -426,7 +426,7 @@ class GuiTheme:
|
||||
syntaxPath = os.path.join(syntaxDir, syntaxFile)
|
||||
if not os.path.isfile(syntaxPath):
|
||||
continue
|
||||
logger.verbose("Checking theme syntax for '%s'" % syntaxFile)
|
||||
logger.verbose("Checking theme syntax for '%s'", syntaxFile)
|
||||
try:
|
||||
with open(syntaxPath, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
@@ -441,7 +441,7 @@ class GuiTheme:
|
||||
syntaxName = confParser.get("Main", "name")
|
||||
if len(syntaxFile) > 5 and syntaxName != "":
|
||||
self.syntaxList.append((syntaxFile[:-5], syntaxName))
|
||||
logger.verbose("Syntax name is '%s'" % syntaxName)
|
||||
logger.verbose("Syntax name is '%s'", syntaxName)
|
||||
|
||||
self.syntaxList = sorted(self.syntaxList, key=lambda x: x[1])
|
||||
|
||||
@@ -462,10 +462,10 @@ class GuiTheme:
|
||||
outData.append(int(inData[1]))
|
||||
outData.append(int(inData[2]))
|
||||
except Exception:
|
||||
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
||||
logger.error("Could not load theme colours for '%s' from config file", cnfName)
|
||||
outData = [0, 0, 0]
|
||||
else:
|
||||
logger.warning("Could not find theme colours for '%s' in config file" % cnfName)
|
||||
logger.warning("Could not find theme colours for '%s' in config file", cnfName)
|
||||
outData = [0, 0, 0]
|
||||
return outData
|
||||
|
||||
@@ -480,7 +480,7 @@ class GuiTheme:
|
||||
readCol.append(int(inData[1]))
|
||||
readCol.append(int(inData[2]))
|
||||
except Exception:
|
||||
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
||||
logger.error("Could not load theme colours for '%s' from config file", cnfName)
|
||||
return
|
||||
if len(readCol) == 3:
|
||||
self.guiPalette.setColor(paletteVal, QColor(*readCol))
|
||||
@@ -637,7 +637,7 @@ class GuiIcons:
|
||||
self.themeMap = {}
|
||||
checkPath = os.path.join(self.mainConf.iconPath, self.mainConf.guiIcons)
|
||||
if os.path.isdir(checkPath):
|
||||
logger.debug("Loading icon theme '%s'" % self.mainConf.guiIcons)
|
||||
logger.debug("Loading icon theme '%s'", self.mainConf.guiIcons)
|
||||
self.iconPath = checkPath
|
||||
self.confFile = os.path.join(checkPath, self.confName)
|
||||
else:
|
||||
@@ -649,7 +649,7 @@ class GuiIcons:
|
||||
with open(self.confFile, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
except Exception:
|
||||
logger.error("Could not load icon theme settings from: %s" % self.confFile)
|
||||
logger.error("Could not load icon theme settings from: %s", self.confFile)
|
||||
nw.logException()
|
||||
return False
|
||||
|
||||
@@ -669,16 +669,16 @@ class GuiIcons:
|
||||
if confParser.has_section(cnfSec):
|
||||
for iconName, iconFile in confParser.items(cnfSec):
|
||||
if iconName not in self.ICON_MAP:
|
||||
logger.error("Unknown icon name '%s' in config file" % iconName)
|
||||
logger.error("Unknown icon name '%s' in config file", iconName)
|
||||
else:
|
||||
iconPath = os.path.join(self.iconPath, iconFile)
|
||||
if os.path.isfile(iconPath):
|
||||
self.themeMap[iconName] = iconPath
|
||||
logger.verbose("Icon slot '%s' using file '%s'" % (iconName, iconFile))
|
||||
logger.verbose("Icon slot '%s' using file '%s'", iconName, iconFile)
|
||||
else:
|
||||
logger.error("Icon file '%s' not in theme folder" % iconFile)
|
||||
logger.error("Icon file '%s' not in theme folder", iconFile)
|
||||
|
||||
logger.info("Loaded icon theme '%s'" % self.mainConf.guiIcons)
|
||||
logger.info("Loaded icon theme '%s'", self.mainConf.guiIcons)
|
||||
|
||||
return True
|
||||
|
||||
@@ -691,14 +691,14 @@ class GuiIcons:
|
||||
map. This function always returns a QSwgWidget.
|
||||
"""
|
||||
if decoKey not in self.DECO_MAP:
|
||||
logger.error("Decoration with name '%s' does not exist" % decoKey)
|
||||
logger.error("Decoration with name '%s' does not exist", decoKey)
|
||||
return QPixmap()
|
||||
|
||||
imgPath = os.path.join(
|
||||
self.mainConf.assetPath, "images", self.DECO_MAP[decoKey]
|
||||
)
|
||||
if not os.path.isfile(imgPath):
|
||||
logger.error("Decoration file '%s' not in assets folder" % self.DECO_MAP[decoKey])
|
||||
logger.error("Decoration file '%s' not in assets folder", self.DECO_MAP[decoKey])
|
||||
return QPixmap()
|
||||
|
||||
theDeco = QPixmap(imgPath)
|
||||
@@ -742,7 +742,7 @@ class GuiIcons:
|
||||
if not os.path.isdir(themePath) or themeDir == self.fbackName:
|
||||
continue
|
||||
themeConf = os.path.join(themePath, self.confName)
|
||||
logger.verbose("Checking icon theme config for '%s'" % themeDir)
|
||||
logger.verbose("Checking icon theme config for '%s'", themeDir)
|
||||
try:
|
||||
with open(themeConf, mode="r", encoding="utf8") as inFile:
|
||||
confParser.read_file(inFile)
|
||||
@@ -755,7 +755,7 @@ class GuiIcons:
|
||||
if confParser.has_section("Main"):
|
||||
if confParser.has_option("Main", "name"):
|
||||
themeName = confParser.get("Main", "name")
|
||||
logger.verbose("Theme name is '%s'" % themeName)
|
||||
logger.verbose("Theme name is '%s'", themeName)
|
||||
if themeName != "":
|
||||
self.themeList.append((themeDir, themeName))
|
||||
|
||||
@@ -774,7 +774,7 @@ class GuiIcons:
|
||||
a QIcon.
|
||||
"""
|
||||
if iconKey not in self.ICON_MAP:
|
||||
logger.error("Requested unknown icon name '%s'" % iconKey)
|
||||
logger.error("Requested unknown icon name '%s'", iconKey)
|
||||
return QIcon()
|
||||
|
||||
# If we just want the app icon, return it right away
|
||||
@@ -785,17 +785,17 @@ class GuiIcons:
|
||||
# First in the theme folder
|
||||
if iconKey in self.themeMap:
|
||||
relPath = os.path.relpath(self.themeMap[iconKey], self.mainConf.iconPath)
|
||||
logger.verbose("Loading: %s" % relPath)
|
||||
logger.verbose("Loading: %s", relPath)
|
||||
return QIcon(self.themeMap[iconKey])
|
||||
|
||||
# Next, we try to load the Qt style icons
|
||||
if self.ICON_MAP[iconKey][0] is not None:
|
||||
logger.verbose("Loading icon '%s' from Qt QStyle.standardIcon" % iconKey)
|
||||
logger.verbose("Loading icon '%s' from Qt QStyle.standardIcon", iconKey)
|
||||
return qApp.style().standardIcon(self.ICON_MAP[iconKey][0])
|
||||
|
||||
# If we're still here, try to set from system theme
|
||||
if self.ICON_MAP[iconKey][1] is not None:
|
||||
logger.verbose("Loading icon '%s' from system theme" % iconKey)
|
||||
logger.verbose("Loading icon '%s' from system theme", iconKey)
|
||||
if QIcon().hasThemeIcon(self.ICON_MAP[iconKey][1]):
|
||||
return QIcon().fromTheme(self.ICON_MAP[iconKey][1])
|
||||
|
||||
@@ -805,16 +805,16 @@ class GuiIcons:
|
||||
self.mainConf.iconPath, self.fbackName, "%s-dark.svg" % iconKey
|
||||
)
|
||||
if os.path.isfile(fbackIcon):
|
||||
logger.verbose("Loading icon '%s' from fallback theme (dark mode)" % iconKey)
|
||||
logger.verbose("Loading icon '%s' from fallback theme (dark mode)", iconKey)
|
||||
return QIcon(fbackIcon)
|
||||
|
||||
fbackIcon = os.path.join(self.mainConf.iconPath, self.fbackName, "%s.svg" % iconKey)
|
||||
if os.path.isfile(fbackIcon):
|
||||
logger.verbose("Loading icon '%s' from fallback theme (light mode)" % iconKey)
|
||||
logger.verbose("Loading icon '%s' from fallback theme (light mode)", iconKey)
|
||||
return QIcon(fbackIcon)
|
||||
|
||||
# Give up and return an empty icon
|
||||
logger.warning("Did not load an icon for '%s'" % iconKey)
|
||||
logger.warning("Did not load an icon for '%s'", iconKey)
|
||||
|
||||
return QIcon()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user