Skip to content

Add canonical log lines and structured JSON logging#301

Merged
JE-Chen merged 2 commits into
devfrom
feat/canonical-log-batch
Jun 21, 2026
Merged

Add canonical log lines and structured JSON logging#301
JE-Chen merged 2 commits into
devfrom
feat/canonical-log-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 21, 2026

Copy link
Copy Markdown
Member

What

logging_instance emits a fixed pipe-delimited string with no JSON option and no trace/span fields, but OTel log-trace correlation needs trace_id/span_id per record.

  • CanonicalLogLine — Stripe-style wide-event accumulator: add/update, timer(name){name}_ms (injectable clock), render/emit.
  • bind_trace_context(line, ctx) — attaches a SpanContext's ids.
  • JSONLogFormatter — a logging.Formatter emitting one JSON object per record including trace_id/span_id and extra= fields.

The log-trace correlation counterpart to trace_context.

Layers

  • Headless core: utils/canonical_log/ (pure stdlib json/logging, zero PySide6).
  • Facade: 3 symbols + __all__.
  • Executor: AC_canonical_log.
  • MCP: ac_canonical_log (read-only).
  • Script Builder: under Report.
  • Tests: test/unit_test/headless/test_canonical_log_batch.py (8 tests, injected clock).
  • Docs: v93_features_doc.rst (EN + Zh) + toctrees + 3 README What's-new sections.

Verification

  • pytest test/unit_test/headless/test_canonical_log_batch.py → 8 passed.
  • ruff check je_auto_control/ clean; pylint 10.00/10; bandit clean; radon CC clean.
  • Package stays Qt-free.

logging_instance emits a fixed pipe-delimited string with no JSON option
and no trace/span fields, but OTel log-trace correlation needs trace_id /
span_id per record. Add CanonicalLogLine (a Stripe-style wide-event
accumulator with an injectable-clock timer), bind_trace_context, and a
JSONLogFormatter that carries trace context. Wired through facade,
executor (AC_canonical_log), MCP, and the Script Builder with a headless
test batch and EN/Zh docs.
@codacy-production

codacy-production Bot commented Jun 21, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 31 complexity · 0 duplication

Metric Results
Complexity 31
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit c10a39b into dev Jun 21, 2026
2 checks passed
@JE-Chen JE-Chen deleted the feat/canonical-log-batch branch June 21, 2026 19:34
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant