Skip to content

Docs: keep the log-level split where both files say it is - #1579

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:docs/dedup-log-levels-into-logging
Jul 30, 2026
Merged

Docs: keep the log-level split where both files say it is#1579
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:docs/dedup-log-levels-into-logging

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

docs/logging.md opens with

For the user-facing model — one Python knob and the CLI flags — see testing.md § Log levels. This file documents the implementation.

and docs/testing.md § Log levels points back for implementation details. The split is declared in both directions. Neither file held it:

  • testing.md carried the simpler_log_init / HostLogger / InitArgs chain, the cann_level() → CANN mapping, and the fork-time threshold propagation — all mechanism, in the file that says it is not about mechanism.
  • logging.md restated the one-shot snapshot semantics that testing.md also spelled out.

That is the shape that produces a doc which silently lies: #1475 retired the verbose V-tiers and had two places to land.

After

testing.md answers only what a test author needs — the integer layout, the macro→level table, how to set the threshold, and the two consequences:

  • the threshold is snapshotted once at Worker.init(), so logger.setLevel(...) afterwards does not reach a live worker;
  • onboard AICPU severity comes from CANN, and a pre-set ASCEND_GLOBAL_LOG_LEVEL wins over the Python logger.

logging.md gains what moved, under ## Configuration flow:

  • the CANN mapping as a table (timing and warn both → CANN WARN, which is why the default threshold does not open CANN's INFO stream);
  • the ASCEND_GLOBAL_LOG_LEVEL-wins rule;
  • forked chip subprocesses, which were documented nowhere else: L3/L4 parents snapshot the threshold before fork() and pass it explicitly to _chip_process_loop, rather than letting the child re-read a logger it never configured.

Not a size reduction

testing.md loses 8 lines (788 → 780); logging.md gains 30 (282 → 312). The gain is that one topic now has one owner per aspect. testing.md is still 780 lines / 16 H2 and well past the soft target in .claude/rules/doc-consistency.md §6 — splitting it is a separate decision, not folded in here.

Testing

  • mkdocs build --strict passes
  • markdownlint-cli2 --config tests/lint/.markdownlint.yaml — 0 errors on both files
  • Both cross-links still resolve: logging.md#configuration-flow and testing.md#log-levels (neither heading renamed)
  • Every moved claim checked against source — dlog_setlevel / cann_level() in src/common/platform/*/host/c_api_shared.cpp, the --log-level choices in conftest.py

Docs only.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f8c29960-ada8-474f-aee9-8d6ffc270593

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Logging documentation now describes worker threshold propagation and CANN-owned onboard severity. Testing documentation reorganizes log-level configuration guidance, adds CLI examples, and links detailed behavior to the logging configuration documentation.

Changes

Logging documentation

Layer / File(s) Summary
Configuration flow documentation
docs/logging.md
Documents threshold propagation to forked chip subprocesses, CANN severity ownership, environment precedence, and Simple-to-CANN level mapping.
Testing log-level guidance
docs/testing.md
Adds log-level CLI examples, clarifies one-time threshold snapshots and output routing, and links to the logging configuration flow.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • hw-native-sys/simpler#1409: Updates the default ASCEND_GLOBAL_LOG_LEVEL for multi-round timing runs, matching this PR’s CANN severity and TIMING documentation.

Poem

I’m a rabbit with logs in a row,
Watching thresholds fork and flow.
CANN keeps onboard levels bright,
TIMING rests at WARN tonight.
Docs now guide each debugging hop!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly reflects the documentation split between logging.md and testing.md.
Description check ✅ Passed The description matches the docs reorganization and cross-linking described in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/logging.md`:
- Around line 278-281: Update the dlog_setlevel guidance in the CANN logging
documentation to state that it must be called before the device context is
opened; calls made after device initialization do not affect device-side
logging. Keep the existing ASCEND_GLOBAL_LOG_LEVEL and dlog_setlevel
configuration details unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cbf21621-9dcd-4819-be36-1bc047976a53

📥 Commits

Reviewing files that changed from the base of the PR and between ca22a8f and 55d6a54.

📒 Files selected for processing (2)
  • docs/logging.md
  • docs/testing.md

Comment thread docs/logging.md Outdated
@ChaoWao
ChaoWao force-pushed the docs/dedup-log-levels-into-logging branch from 55d6a54 to 373ec15 Compare July 29, 2026 09:29
`logging.md` opens by pointing at `testing.md § Log levels` for the
user-facing model and claiming implementation for itself; `testing.md § Log
levels` points back for implementation. The split is declared in both
directions, and neither file held it — testing.md carried the
`simpler_log_init` / `HostLogger` / `InitArgs` chain, the `cann_level()`
mapping, and the fork-time threshold propagation, all of which are mechanism,
and logging.md restated the snapshot semantics.

testing.md now answers only what a test author needs: what the levels are,
which macro lands where, how to set the threshold, and the two consequences —
the threshold is snapshotted once at `Worker.init()`, and onboard AICPU
severity comes from CANN, where a pre-set `ASCEND_GLOBAL_LOG_LEVEL` wins.

logging.md gains what moved: the CANN mapping as a table under Configuration
flow, plus the forked-subprocess rule, which was documented nowhere else —
the parent snapshots before `fork()` and passes the value explicitly to
`_chip_process_loop` rather than letting the child re-read a logger it never
configured.

Both files now also state the deadline for configuring CANN severity by hand:
it must happen before `Worker.init()`. `init_log_switch()` reads CANN once at
the top of the AICPU init kernel and latches the result into
`g_is_log_enable_*`; every later `LOG_*` tests those flags and never asks CANN
again, and that kernel runs inside `Worker.init()`. A `dlog_setlevel` after
that call silently does nothing to device-side logging.

Not a size reduction: testing.md loses 6 lines and logging.md gains 37. The
point is that one topic now has one owner per aspect, so a change like hw-native-sys#1475
has one place to land instead of two.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ChaoWao
ChaoWao merged commit 1a77c3f into hw-native-sys:main Jul 30, 2026
14 checks passed
@ChaoWao
ChaoWao deleted the docs/dedup-log-levels-into-logging branch July 30, 2026 01:15
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