Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devenv: convert logging to use tracing ecosystem #1566

Merged
merged 21 commits into from
Nov 28, 2024
Merged

Conversation

sandydoo
Copy link
Member

@sandydoo sandydoo commented Nov 1, 2024

Converts devenv to use the tracing ecosystem for logging.

Usage

You can now use tracing macros to output events: debug!, info!, error!, etc.
Adding a devenv.is_user_message boolean field to the event formats it as a step.

Steps can also be created with spans: info_span! , error_span!, etc.
Adding a devenv.user_message = "..." field to the span makes it output events for the start and end of the span.
The latter also outputs timings.

RUST_LOG

Logging can be additionally configured using the RUST_LOG environment variable.

Logging formats

devenv supports two log formats via the --log-format option: cli and tracing-full.

  • --log-format cli

    The default. Mimics the existing CLI logging format.

    Screenshot 2024-11-29 at 00 49 56
  • --log-format tracing-full

    Outputs traces in the tracing library's Full style. Useful in conjunction with the --verbose flag to debug issues.
    Screenshot 2024-11-29 at 00 50 13

--verbose drops the log level to debug and outputs all Nix logs.

Introduces:

  • A DevenvLayer tracing layer that tracks metadata about spans. This tracks span timings, errors, and emits events when the span is created and closed.
  • A DevenvFormat event formatter that mimics the existing CLI formatting.

@sandydoo sandydoo added enhancement New feature or request cli Related to the devenv CLI labels Nov 1, 2024
Copy link

cloudflare-workers-and-pages bot commented Nov 8, 2024

Deploying devenv with  Cloudflare Pages  Cloudflare Pages

Latest commit: d9fff24
Status: ✅  Deploy successful!
Preview URL: https://d6da1fc9.devenv.pages.dev
Branch Preview URL: https://migrate-logging.devenv.pages.dev

View logs

devenv-run-tests/src/main.rs Outdated Show resolved Hide resolved
devenv/src/cnix.rs Outdated Show resolved Hide resolved
@sandydoo sandydoo force-pushed the migrate-logging branch 2 times, most recently from b659346 to 7341a94 Compare November 27, 2024 15:47
@sandydoo sandydoo marked this pull request as ready for review November 28, 2024 20:53
@domenkozar domenkozar merged commit 51abcb7 into main Nov 28, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the devenv CLI enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants