Logging¶
datacoolie.logging exposes two application-facing logger types: SystemLogger for operational
records and ExecutionLogger for structured execution records. Runtime capture, context
propagation, formatting, and persistence modules are internal implementation details.
LogCategory.EXECUTION and LogCategory.SYSTEM define the two default top-level folders used by
the Driver when it creates loggers from a shared log_base_path.
constants
¶
Logging-owned enum values and shared constants.
LogCategory
¶
Bases: str, Enum
Top-level log directories under a shared log_base_path.
LogType
¶
Bases: str, Enum
Structured log record kind identifiers.
LogLevel
¶
Bases: str, Enum
Supported framework logging levels.
PersistenceMode
¶
Bases: str, Enum
Remote JSON Lines persistence strategy.
StorageMode
¶
Bases: str, Enum
Local fallback storage used by captured Python records.
ConsoleColor
¶
Bases: str, Enum
Console color policy for human-readable logging output.
LogEvent
¶
Bases: str, Enum
Stable names for framework diagnostic lifecycle events.
FlushResult
¶
Bases: str, Enum
Outcome of a non-raising writer flush attempt.
WRITTEN is the only outcome that represents a completed remote write.
NO_WORK and IN_FLIGHT are deliberately distinct so lifecycle code
cannot report a skipped operation as successful.
execution_logger
¶
Structured execution and job-runtime logging.
ExecutionLogger
¶
ExecutionLogger(
config: LogConfig,
platform: Optional[BasePlatform] = None,
)
Bases: BaseLogger
Persist terminal dataflow rows and one mutable job summary.
The projection module owns record shape while this logger owns counters and
lifecycle; :class:JsonLogWriter owns encoded buffering and remote
publication. Dataflow rows are accepted only
at the terminal observational boundary so a killed operation does not
create a misleading partial record.
finish_job
¶
finish_job(
status: str,
*,
end_time: Optional[datetime] = None,
message: Optional[str] = None,
) -> None
Set the business outcome used by the final job snapshot.
log
¶
log(
dataflow: DataFlow, runtime_info: DataFlowRuntimeInfo
) -> None
Record one terminal dataflow or maintenance observation.
create_execution_logger
¶
create_execution_logger(
output_path: Optional[str] = None,
platform: Optional[BasePlatform] = None,
config: Optional[LogConfig] = None,
) -> ExecutionLogger
Create an execution logger with the framework defaults.
system_logger
¶
Python system-log capture backed by the shared JSON Lines writer.
SystemLogger
¶
SystemLogger(
config: LogConfig,
platform: Optional[BasePlatform] = None,
)
Bases: BaseLogger
Capture framework Python logs and persist them as JSON Lines.
create_system_logger
¶
create_system_logger(
output_path: Optional[str] = None,
log_level: str = INFO.value,
file_level: str = DEBUG.value,
platform: Optional[BasePlatform] = None,
storage_mode: str = MEMORY.value,
config: Optional[LogConfig] = None,
) -> SystemLogger
Create a system logger with framework defaults.
Default console formatting shows optional dataflow_id and event_name in separate brackets
after the logger name, for example [orders] [dataflow.started]. Missing values are omitted.
The default console omits dataflow_run_id; persisted records retain it as a separate field,
and custom formats can explicitly render it with %(dataflow_run_id)s.
Dataflow lifecycle and replay messages include the authored name and logical route:
name | source_full_table_name → destination_full_table_name | details.
The emitter builds this message without adding name or route fields to logging context.
Use the structured ID and event fields for filtering and persistence.
DataCoolieRunConfig.run_attributes is documented with the runtime configuration API · Run configuration. It is persisted
only in the job-runtime JSON record as the deterministic run_attributes string. Persisted
records use log_schema_version=7. A logger's log_session_id correlates records from one
activated Driver logging session; job_id identifies the job lifecycle, while dataflow_run_id
identifies an individual execution or replay-chunk instance (dataflow_id identifies the logical
flow). LogConfig.console_color accepts "auto", "always", or "never" and affects only the
owned console handler; capture and persisted JSON remain plain.
v7 runtime projection¶
The v7 dataflow record keeps authored metadata fields and adds an explicit runtime shape:
read_requestis a nullable native object containing the original source request. Watermark-shaped bounds use the tagged scalar representation;reference_timeremains an ISO timestamp.attemptsis a native array of detached terminal attempt objects. It is not a JSON-encoded string and it is empty when no pipeline attempt was admitted.- Each attempt contains
source,transform,destination, andwatermarkphase objects. Sourceselectionand watermarkcandidateare native nested objects; a candidate is{ "values": ..., "kind": ... }ornull. metricsis a native object with nullable counts and byte measurements. A reported count, including0, is retained; unentered work and unavailable measurements arenull.retry_attemptsand the root identity/timing/status fields remain derived root fields.
Job and replay metrics sum the available observations per field. For example,
100 + null totals 100, 0 + null totals 0, and an all-null or empty
population stays null. These are observed totals; they do not imply every
operation was measured. No additional eligibility field is persisted.
Diagnostic detail is bounded per persisted dataflow or system record by the shared
LogConfig.diagnostic_max_bytes budget (65,536 bytes by default). The encoder keeps a valid
UTF-8 prefix, omits a value when it cannot preserve a valid projection, and may add at most 16
diagnostic_issues markers with field and reason (truncated, omitted, or invalid).
The complete JSON Lines record is capped by LogConfig.max_record_bytes (1 MiB by default).
See diagnostic limits and loss accounting
for the shared message/detail budget, marker semantics and exact scope of job drop counters.
The root does not duplicate phase fields such as source_read_range,
source_watermark_end, flattened source/transform/destination counts, or
checkpoint aliases. System records may carry an optional positive
attempt_number for diagnostic correlation. Historical records, including v6,
retain their original values and meaning; the v7 writer does not rewrite them.