Skip to content

Commit

Permalink
loadFonts to check if there is a logger when debug==True
Browse files Browse the repository at this point in the history
For the following use case:
UFOProcessor object is initialised with `debug=False`, no logger is started.
Then, in a scripted context, the debug flag is set to True. But this is just an attribute, so there is no logger.
Then `loadFonts` checks both `debug` and `logger` and calls `startLog` to create one if needed.
  • Loading branch information
LettError committed Dec 6, 2024
1 parent e8593dc commit a08c050
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Lib/ufoProcessor/ufoOperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,11 @@ def getAxis(self, axisName):
# loading and updating fonts
def loadFonts(self, reload=False):
# Load the fonts and find the default candidate based on the info flag
if self.logger is None and self.debug:
# in some cases the UFOProcessor is initialised without debug
# and then it is switched on afterwards. So have to check if
# we have a logger before proceding.
self.startLog()
self.glyphNames = list({glyphname for font in self.fonts.values() for glyphname in font.keys()})
if self._fontsLoaded and not reload:
if self.debug:
Expand Down Expand Up @@ -1761,8 +1766,12 @@ def _copyFontInfo(self, sourceInfo, targetInfo):
if ds5Path is None:
doc = UFOOperator()
else:
doc = UFOOperator(ds5Path, useVarlib=True, debug=debug)
doc = UFOOperator(ds5Path, useVarlib=True, debug=False)
print("Initialised without debug, no logger:", doc.logger)
doc.debug=True
print("Set debug to True, after initialisation:", doc.debug)
doc.loadFonts()
print("loadFonts checks and creates a logger if needed:", doc.logger)


# test the getLibEntryMutator
Expand Down

0 comments on commit a08c050

Please sign in to comment.