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

feat(cli): logging support #483

Merged
merged 5 commits into from
Oct 6, 2023
Merged

feat(cli): logging support #483

merged 5 commits into from
Oct 6, 2023

Conversation

ematipico
Copy link
Member

Summary

This PR adds support for logging to the Biome CLI.

Logging in the CLI differs from the Daemon, so we had to provide a different subscriber with different options.

For the time being I decided to use the built-in formatters provided by tracing_subscriber, which are more than enough for what we have to do.

In production, the CLI will support the following levels: debug, info, warn and error. Locally, when debugging we can also use trace, but at the moment, I didn't provide a way to enable it. I'll do it later with more instructions for contributors.

Here's how logs will look like:

Compact:

2023-10-05T08:29:04.864247Z  INFO biome::worker_2 Process check:Processes linting:Pulling diagnostics: crates/biome_service/src/file_handlers/javascript.rs: Analyze file ./website/src/playground/components/Resizable.tsx path="./website/src/playground/components/Resizable.tsx" path="./website/src/playground/components/Resizable.tsx" categories=RuleCategories(LINT)
  2023-10-05T08:29:04.864290Z  INFO biome::worker_7 Process check:Processes formatting: crates/biome_service/src/file_handlers/javascript.rs: Format file ./website/src/playground/components/Tabs.tsx path="./website/src/playground/components/Tabs.tsx" path="./website/src/playground/components/Tabs.tsx"
  2023-10-05T08:29:04.879332Z  INFO biome::worker_2 Process check:Processes formatting:Pulling diagnostics: crates/biome_service/src/file_handlers/javascript.rs: Analyze file ./website/src/playground/components/Resizable.tsx path="./website/src/playground/components/Resizable.tsx" path="./website/src/playground/components/Resizable.tsx" categories=RuleCategories(SYNTAX)
  2023-10-05T08:29:04.879383Z  INFO biome::worker_2 Process check:Processes formatting: crates/biome_service/src/file_handlers/javascript.rs: Format file ./website/src/playground/components/Resizable.tsx path="./website/src/playground/components/Resizable.tsx" path="./website/src/playground/components/Resizable.tsx"
  

Pretty:

  2023-10-05T08:27:01.954727Z  INFO  Analyze file ./website/src/playground/components/Resizable.tsx
    at crates/biome_service/src/file_handlers/javascript.rs:298 on biome::worker_5
    in Pulling diagnostics with categories: RuleCategories(SYNTAX)
    in Processes formatting with path: "./website/src/playground/components/Resizable.tsx"
    in Process check with path: "./website/src/playground/components/Resizable.tsx"

Json

{"timestamp":"2023-10-05T08:37:11.412692Z","level":"INFO","message":"Analyze file ./website/src/playground/components/Resizable.tsx","filename":"crates/biome_service/src/file_handlers/javascript.rs","span":{"categories":"RuleCategories(SYNTAX)","name":"Pulling diagnostics"},"spans":[{"path":"\"./website/src/playground/components/Resizable.tsx\"","name":"Process check"},{"path":"\"./website/src/playground/components/Resizable.tsx\"","name":"Processes formatting"},{"categories":"RuleCategories(SYNTAX)","name":"Pulling diagnostics"}],"threadName":"biome::worker_5"}

Test Plan

I don't think we need tests here, although I locally checked that logs are written to console.

@ematipico ematipico temporarily deployed to Website deployment October 5, 2023 08:38 — with GitHub Actions Inactive
@ematipico ematipico requested a review from a team October 5, 2023 08:38
@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-Parser Area: parser A-Website Area: website L-CSS Language: CSS A-Changelog Area: changelog labels Oct 5, 2023
@ematipico ematipico temporarily deployed to Website deployment October 5, 2023 08:44 — with GitHub Actions Inactive
@ematipico ematipico temporarily deployed to Website deployment October 5, 2023 09:08 — with GitHub Actions Inactive
@ematipico ematipico temporarily deployed to Website deployment October 5, 2023 09:30 — with GitHub Actions Inactive
@ematipico ematipico temporarily deployed to Website deployment October 5, 2023 11:22 — with GitHub Actions Inactive
@ematipico ematipico temporarily deployed to Website deployment October 6, 2023 08:07 — with GitHub Actions Inactive
@ematipico ematipico merged commit 075b9c4 into main Oct 6, 2023
17 checks passed
@ematipico ematipico deleted the feat/logging branch October 6, 2023 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-CLI Area: CLI A-Parser Area: parser A-Project Area: project A-Website Area: website L-CSS Language: CSS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant