With PreTeXtBook/pretext#3046 merged, the core library defines a severity vocabulary for every message it logs. As part of that, level 50 — what Python's logging module calls CRITICAL — is renamed at import time:
logging.addLevelName(logging.CRITICAL, 'FATAL')
addLevelName is global to Python's logging module, so any pretext-cli handler whose format string includes %(levelname)s will now display FATAL on level-50 records. This was deliberate on the library side (in the new vocabulary, fatal means "processing halts, no output expected" — and the library now guarantees that meaning), but the display name at the console is rightly the CLI's choice.
If you prefer your users see CRITICAL, either of these is cut/paste ready.
Option 1 — a single call, global. Run it any time after the core library has been imported (the last call to addLevelName wins):
import logging
logging.addLevelName(logging.CRITICAL, "CRITICAL")
Option 2 — scoped to your handler, immune to import order. A formatter that rebrands only what it displays, leaving the record itself untouched:
import copy
import logging
class CriticalNotFatal(logging.Formatter):
"""Display level 50 as CRITICAL, whatever the logging module calls it."""
def format(self, record):
if record.levelno == logging.CRITICAL:
record = copy.copy(record)
record.levelname = "CRITICAL"
return super().format(record)
# wherever pretext-cli configures its console handler:
handler.setFormatter(CriticalNotFatal("%(levelname)s: %(message)s"))
Two related heads-ups from the same change, so they don't surprise you later:
-
Two new levels interleave with the standard five and will appear in the ptxlogger stream: FALLBACK (25 — bad input, but a sensible default was substituted and output is complete) and BUG (45 — an internal PreTeXt defect, not the author's fault). Handlers pass them through automatically; only level-filtering logic that assumes exactly five levels would need a look.
-
A fatal message now raises: log.fatal(...) logs at level 50 and then raises PreTeXtFatal (defined in the core's common module, re-exported by the main module). Catching it lets the CLI distinguish a deliberate, already-logged halt from an unexpected crash — the foundation for a clean two-state report ("build finished with errors" versus "build did not happen"). Happy to discuss that in its own issue when useful.
The full vocabulary is documented in a new "Messages and Severity" chapter of the Developer Guide.
Claude Fable 5, acting as a coding assistant for Rob Beezer
With PreTeXtBook/pretext#3046 merged, the core library defines a severity vocabulary for every message it logs. As part of that, level 50 — what Python's
loggingmodule callsCRITICAL— is renamed at import time:addLevelNameis global to Python'sloggingmodule, so any pretext-cli handler whose format string includes%(levelname)swill now displayFATALon level-50 records. This was deliberate on the library side (in the new vocabulary, fatal means "processing halts, no output expected" — and the library now guarantees that meaning), but the display name at the console is rightly the CLI's choice.If you prefer your users see
CRITICAL, either of these is cut/paste ready.Option 1 — a single call, global. Run it any time after the core library has been imported (the last call to
addLevelNamewins):Option 2 — scoped to your handler, immune to import order. A formatter that rebrands only what it displays, leaving the record itself untouched:
Two related heads-ups from the same change, so they don't surprise you later:
Two new levels interleave with the standard five and will appear in the
ptxloggerstream:FALLBACK(25 — bad input, but a sensible default was substituted and output is complete) andBUG(45 — an internal PreTeXt defect, not the author's fault). Handlers pass them through automatically; only level-filtering logic that assumes exactly five levels would need a look.A fatal message now raises:
log.fatal(...)logs at level 50 and then raisesPreTeXtFatal(defined in the core'scommonmodule, re-exported by the main module). Catching it lets the CLI distinguish a deliberate, already-logged halt from an unexpected crash — the foundation for a clean two-state report ("build finished with errors" versus "build did not happen"). Happy to discuss that in its own issue when useful.The full vocabulary is documented in a new "Messages and Severity" chapter of the Developer Guide.
Claude Fable 5, acting as a coding assistant for Rob Beezer