logger¶
Algan’s library logger, backed by Python’s standard logging module.
All of Algan’s diagnostic and progress output goes through the "algan"
logger. By default it prints bare messages to stderr at INFO level (so
render-progress messages stay visible, as they always were). To quiet or
raise verbosity, either:
set the
ALGAN_LOG_LEVELenvironment variable (e.g.ALGAN_LOG_LEVEL=WARNINGsilences progress output), orcall
set_log_level()at any time, orattach your own handlers to
logging.getLogger("algan")after callinglogger.handlers.clear().
Levels are thresholds, not selectors: a level shows itself and everything more
severe, so INFO also shows warnings and errors.
Algan adds one level of its own, PERF, between DEBUG and INFO:
ALGAN_LOG_LEVEL = PERF # or set_log_level("PERF")
It carries the renderer’s self-healing events – the batch splits and pool
retries it performs when a chunk does not fit. Those are the memory model
working as designed, not faults, so they are below INFO and invisible by
default; they used to be WARNING, which made a healthy render look broken
and was the only thing left on screen for anyone who set WARNING to quiet
the progress output. Turn PERF on when a render is slower than expected and
you want to see how it is being budgeted. Being below INFO, it also means
DEBUG includes these messages.
How a render reports its progress is a separate choice from whether it is
logged at all, and is controlled by set_progress_style() or the
ALGAN_PROGRESS environment variable – see PROGRESS_STYLES.
Functions
- apply_environment_logging()[source]¶
Apply
ALGAN_LOG_LEVELandALGAN_PROGRESSto the live logger.Called once as this module is imported, and again by the render daemon at the start of each run (
algan.daemon.execute) so a warm process reports at the verbosity the client asked for. That second call is what makes both variables honestly live rather than baked in at import: neither configures anything a kernel or a module-level default could have frozen – the level lives on alogging.Loggerand the style in a module global, andset_log_level()/set_progress_style()move both at any time – so refusing a warm run over a difference in one would be refusing over nothing.An unset variable resets its setting to the shipped default rather than being skipped. That is what makes the daemon call safe: neither of these lives in
SETTINGS.snapshot(), soreset_state()does not restore them, and skipping the unset case would leave one client’sALGAN_LOG_LEVEL=DEBUGrunning every later client’s script.A bad value is reported through the logger and otherwise ignored, on the same principle as every other environment read: a mistyped diagnostic knob must not abort a render.
- resolve_progress_style()[source]¶
Resolve the configured style to a concrete one for this render.
Returns
"bar","log"or"none";"auto"never survives.Under
"auto"the question being answered is not “is this a terminal” but “will whatever reads stderr act on a carriage return”. Those differ, andisatty()is only a proxy: a captured CI or pytest log has one kept verbatim, while several consoles that are not terminals (PyCharm’s run console, a notebook) render one correctly. So capture is ruled out first, then a terminal is taken at its word, then the known bar-capable consoles get their exception.
- set_log_level(level)[source]¶
Set the verbosity of Algan’s console output.
- Parameters:
level – A standard
logginglevel name or value, e.g."WARNING"to silence progress messages or"DEBUG"for extra detail. Algan’s own"PERF"(seePERF) sits between the two and adds the renderer’s budget and recovery diagnostics to the default output.
Notes
This also holds the noisier third-party loggers Algan pulls in (currently Manim’s) to the same level, so one call quiets the whole console.
- set_progress_style(style)[source]¶
Set how renders report progress.
- Parameters:
style – One of
PROGRESS_STYLES:"bar","log","none"or"auto"(the default).- Raises:
ValueError – If
styleis not one ofPROGRESS_STYLES.
Notes
Progress output is emitted at
INFO, soset_log_level("WARNING")silences it whatever the style.