tracing-subscriber-init 0.2.7

A trait and some functions to make tracing subscriber initialization a bit easier
Documentation
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Overview

`tracing-subscriber-init` is a Rust library crate that provides a `TracingConfig` trait and convenience functions to reduce boilerplate when initializing `tracing-subscriber`. MSRV is 1.88.0, edition 2024.

## Commands

### Build
```sh
cargo build
cargo build --all-features
```

### Test
```sh
# Run all tests (preferred — uses nextest)
cargo nextest run

# Run all feature combinations
cargo matrix nextest run

# Run a single test by name
cargo nextest run <test_name>

# Run tests with a specific feature
cargo nextest run --features json
```

### Lint
```sh
cargo fmt
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -Dwarnings

# Via cargo-matrix (matches CI)
cargo matrix clippy --all-targets -- -Dwarnings
```

### Documentation
```sh
cargo +nightly doc --all-features
```

### Full pipeline (via cargo-rake)
```sh
cargo rake          # fmt → clippy → build → test → coverage
cargo rake most     # same as default
cargo rake all      # puc + most + audit + clean
cargo rake audit    # cargo-audit against .cargo/audit.toml's ignore list
cargo rake release  # push the current vX.Y.Z tag, wait for repomon to verify it, publish to crates.io
```

### Coverage
```sh
cargo matrix -F unstable llvm-cov nextest --no-report
cargo llvm-cov report --lcov --output-path lcov.info
cargo llvm-cov report --html
```

## Architecture

The crate has four concerns, one per module:

**`config.rs` — `TracingConfig` trait**
Users implement this trait on their own config structs. It exposes `quiet()` and `verbose()` (both `u8`) plus optional overrides for formatting options (`with_ansi`, `with_target`, `with_thread_ids`, etc.). The `quiet`/`verbose` counts map to `tracing::Level` via `get_effective_level` in `utils.rs`, with different behavior in debug vs. release builds.

**`src/format/` — layer constructors**
Four submodules (`compact`, `full`, `json` [feature-gated], `pretty`) each expose two public functions:
- `foo(config)` → `(fmt::Layer<S, ...>, LevelFilter)` — returns the layer and filter separately so callers can customize the layer (e.g., swap the writer) before attaching the filter.
- `filtered(config)` → `Filtered<fmt::Layer<S, ...>, LevelFilter, S>` — convenience wrapper that pre-attaches the filter.

**`initialize.rs` — subscriber registration**
Three functions (`init`, `try_init`, `set_default`) that accept `Vec<Box<dyn Layer<Registry> + Send + Sync>>`, build a `Registry`, attach the layers, and call the corresponding `tracing-subscriber` method.

**`utils.rs` — helpers**
- `get_effective_level(quiet, verbose)`: debug builds default to `INFO` at 0/0; release builds default to `ERROR` at 0/0.
- `TestAll`: a public `TracingConfig` impl with all options enabled, exported for use in downstream integration tests.

## Feature Flags

| Feature    | Enables |
|------------|---------|
| `json`     | JSON formatter (`json` / `json_filtered`) via `tracing-subscriber/json` |
| `tstime`   | Time formatters (`OffsetTime`, `UtcTime`, etc.) and re-exports of `time` well-known formats |
| `unstable` | Additional nightly-only lints (requires nightly toolchain) |

## Build Script & Lint Configuration

`build.rs` uses the `rustversion` crate to detect nightly and emit `cfg(nightly)`. When on nightly, `lib.rs` activates an exhaustive `deny()` list covering rustc, clippy, and rustdoc lints. The `unstable` feature adds a further set of nightly-unstable lints. All feature-matrix CI runs use `--all-features`; the `unstable` feature is only activated for coverage runs.

## CI

CI runs on [repomon](https://github.com/rustyhorde/repomon), a self-hosted, git-push-triggered daemon — there is no `.github` directory. Workflow config lives in `.repomon/*.toml`:

- `.repomon/test.toml` — every push, one job per platform (Linux, macOS, Windows), runs `cargo rake test` (build → nextest). fmt/clippy/coverage aren't gated in CI; run `cargo rake most`/`all` locally for those. repomon has no toolchain-channel matrixing, so unlike the old GitHub Actions setup this doesn't test MSRV/stable/beta/nightly separately — one default toolchain per platform.
- `.repomon/audit.toml` — fires only on a `vX.Y.Z`/`vX.Y.Z-rc.N` tag push (repomon has no cron/schedule trigger, so this no longer runs daily). Runs `cargo rake audit`, then hands a success marker back to a staging directory.
- `.repomon/release.toml` — same tag-only trigger, one job per platform (`linux-rake`/`macos-rake`/`windows-rake`), each running `cargo rake test` then handing back its own success marker.

Publishing to crates.io is a **local** step, not a repomon job — repomon has no secrets-injection mechanism. `cargo rake release` (`scripts/release/release.fish`) pushes the release tag, waits (`scripts/release/dispatch-remote-builds.fish`) for all four markers (`linux.ok`/`macos.ok`/`windows.ok`/`audit.ok`) to land in `/opt/releases/tracing-subscriber-init/staging/<tag>/`, then runs `cargo publish --locked` (`scripts/release/publish-crates.fish`) — skipped entirely for a `-rc` tag, which is a full dry run of everything else.