Skip to content

Convert remaining println!/eprintln! in examples and benches to arlog_*! #90

Description

@kalwalt

Summary

Convert all remaining println! / eprintln! calls in crates/core/examples/ and crates/core/benches/ to the arlog_*! macros, per the project convention in CLAUDE.md §2 ("Logging — use the arlog system"). PR #85 already migrated simple.rs as the canonical model; finish the job across the rest.

Environment

Reproduction Steps

rg -c 'println!|eprintln!' crates/core/examples/ crates/core/benches/

Actual State (audit at HEAD of dev)

Examples — 152 total occurrences across 6 files:

File println! / eprintln! count
crates/core/examples/barcode.rs 11
crates/core/examples/debug_labeling.rs 4
crates/core/examples/generate_patt.rs 34
crates/core/examples/load_nft.rs 22 (mixes arlog_i! + println! — incomplete)
crates/core/examples/nft_marker_gen.rs 49
crates/core/examples/simple_nft.rs 32

Benches — 1 occurrence:

File Count
crates/core/benches/feature_map_bench.rs 1 (eprintln! for missing-asset skip)

Already converted (reference, not in scope):

Expected Behavior

Each file follows the simple.rs pattern:

  1. Replace println!("...") with arlog_i!("...") for informational output, arlog_e! for errors, arlog_d! for verbose/per-frame.
  2. Replace env_logger::init() (where present) with webarkitlib_rs::arlog::ar_log_init_default().
  3. Add use webarkitlib_rs::{arlog_e, arlog_i}; (or arlog_d / arlog_w as needed).
  4. Add required-features = ["log-helpers"] to the example's [[example]] block in crates/core/Cargo.toml if not already declared (so cargo run --example <name> works without a feature flag inside CI).
  5. Update .github/workflows/ci.yml if any of the converted examples are run there (currently only simple is invoked).

Visual Evidence

PR #85 diffs are the canonical model:

  • crates/core/examples/simple.rs — full conversion
  • crates/core/Cargo.toml — required-features = ["log-helpers"] for simple
  • .github/workflows/ci.yml — --features log-helpers on the cargo run --example simple lines

Impact

Low (quality / consistency only) — does not change runtime behavior of the library. Aligns examples and benches with the convention library code already follows. Keeps newcomers from copying stale println! patterns into new code.

Suggested Approach (one PR per group recommended, NOT one giant PR)

To keep diffs reviewable:

  1. PR 1 — small examples: barcode.rs (11) + debug_labeling.rs (4) + the bench feature_map_bench.rs (1). Easy warm-up.
  2. PR 2 — load_nft.rs finish-up (22 remaining). The "canonical" example per CLAUDE.md still mixes println! with arlog_i!; finish converting it so it's actually canonical.
  3. PR 3 — generators: generate_patt.rs (34) + nft_marker_gen.rs (49). Heavier output volume; review separately.
  4. PR 4 — simple_nft.rs (32). Depends on ffi-backend feature — keep separate so reviewers with non-FFI setups can sign off on the others first.

Each PR:

  • Branch off latest dev, fresh per group.
  • Does not touch CHANGELOG.md.
  • Adds required-features = ["log-helpers"] for any example that doesn't have it yet.
  • Verifies cargo fmt --all -- --check, cargo clippy --all-targets --all-features, cargo build --all-features clean.

Additional Context

  • This is a quality-of-life / consistency cleanup, not a bug fix.
  • Logger-init prerequisite is already documented in crates/core/src/arlog.rs (rustdoc header refresh from the documentation skill, see feat: Port ARToolKit logging system (arLog / arLogv) to Rust — with efficiency analysis #57).
  • For the feature_map_bench.rs eprintln! → consider whether benches (which run under criterion) should use arlog_*! at all, or if eprintln! is acceptable in #[cfg(test)]-style scaffolding. Discussion welcome on the issue.

Labels suggested: chore, area:examples, area:benches, good-first-issue.
Priority: Low.

Activity

  1. maxwelljhuang commented on Apr 26, 2026

    @maxwelljhuang
    Contributor

    Hi @kalwalt

    I'd like to take this on if it's still up for grabs. I'll follow the suggested four-PR breakdown and use simple.rs from #85 as the template. Planning to start with PR 1 (the small examples + the bench) so you can sanity-check the pattern before I move on to the bigger files.

    Will branch off latest dev and run cargo fmt --all -- --check, cargo clippy --all-targets --all-features, and cargo build --all-features before opening each PR. Let me know if anything in the plan should change.

  2. kalwalt commented on Apr 27, 2026

    @kalwalt
    MemberAuthor

    Hi @kalwalt

    I'd like to take this on if it's still up for grabs. I'll follow the suggested four-PR breakdown and use simple.rs from #85 as the template. Planning to start with PR 1 (the small examples + the bench) so you can sanity-check the pattern before I move on to the bigger files.

    Will branch off latest dev and run cargo fmt --all -- --check, cargo clippy --all-targets --all-features, and cargo build --all-features before opening each PR. Let me know if anything in the plan should change.

    @maxwelljhuang you are welcome! Start with the PR 1 starting from dev branch and against dev you can also read our CONTRIBUTING.md explaining how to contribute to the project. 😊

  3. added theissue type on Apr 27, 2026
  4. moved this from Backlog to Ready in Plan to port KPM to ruston Apr 27, 2026
  5. maxwelljhuang commented on Apr 28, 2026

    @maxwelljhuang
    Contributor

    @kalwalt

    Quick scope question on feature_map_bench.rs before I include it in PR 1: the eprintln! for the missing-asset skip can be converted to arlog_w!, but without an initialized logger the bench produces no output for that case (regression vs current behavior). Three options I see:

    1. Convert + add ar_log_init_default() and required-features = ["log-helpers"] to the bench (visibility preserved, slightly wider PR scope).
    2. Leave the eprintln! as bench scaffolding and exclude it from PR 1.
    3. Convert silently and address visibility in a follow-up.

    I'm not sure which option is best right now

  6. kalwalt commented on Apr 29, 2026

    @kalwalt
    MemberAuthor

    @maxwelljhuang go for option 1: add the ar_log_init_default() inside the bench_ar2_gen_feature_map function and convert eprintln! to arlog_e!, add the required-features = ["log-helpers"] in Cargo.toml and you will be fine. If you have other doubt i will help you during the PR.

  7. moved this from Ready to In progress in Plan to port KPM to ruston Apr 29, 2026
  8. kalwalt commented on May 6, 2026

    @kalwalt
    MemberAuthor

    @maxwelljhuang would you continue on this? I will appreciate it. 😊

  9. maxwelljhuang commented on May 6, 2026

    @maxwelljhuang
    Contributor

    Hi @kalwalt , apologies for the delay, I've been a little busy with moving but I'll get right back on it!

  10. kalwalt commented on May 18, 2026

    @kalwalt
    MemberAuthor

    @maxwelljhuang if you have the time and when you have time you can continue on this, It will be a pleasure if you complete the issue. 🙂

  11. kalwalt commented on May 28, 2026

    @kalwalt
    MemberAuthor

    Completed with PR #164

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

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions