logging_utils
Helpers for structured logging context.
Small utilities to produce a contextual logger adapter from common CLTK
containers without introducing circular imports in cltk.core.cltk_logger.
HasGlottologId
bind_from_doc
bind_from_doc(
doc: Doc,
*,
sentence_idx: Optional[int] = None,
prompt_version: Optional[str] = None
) -> logging.LoggerAdapter
Return a structured logger bound with context derived from doc.
Binds the following fields when available
- doc_id: sha1 of
normalized_text(orraw) truncated to 10 chars - sentence_idx: provided by caller
- model:
doc.modelstring - glottolog_id: from
doc.dialectordoc.language - prompt_version: provided by caller
Source code in cltk/core/logging_utils.py
plog
Return a contextual logger for a Pipeline-like object.
Extracts glottolog_id from the object if present and binds it for
consistent, filterable logs during pipeline initialization.
Source code in cltk/core/logging_utils.py
glog
Return a logger bound with a specific glottolog_id.
Small alias used by language/glottolog operations for brevity.