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

Introduce NL_LOG to control logging format #1154

Merged

Conversation

adam-singer
Copy link
Contributor

@adam-singer adam-singer commented Jul 13, 2024

Description

NL_LOG envionment variable is used to control the logging format that tracing_subscriber emits out. We currently want to allow for better ingestion of formatted logs in json.

NL_LOG can be configured with pretty, json, or compact. See Format for more detail on console logging format configurations for tracing_subscriber.

Fixes #1153

Type of change

Please delete options that aren't relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Run from console to see the different log formats

Default

$ cargo run --bin nativelink -- nativelink-config/examples/basic_cas.json
     Running `target/debug/nativelink nativelink-config/examples/basic_cas.json`
  2024-07-13T05:38:08.874357Z  WARN nativelink: Ready, listening on 0.0.0.0:50051
    at src/bin/nativelink.rs:677

  2024-07-13T05:38:08.874826Z  WARN nativelink: Ready, listening on 0.0.0.0:50061
    at src/bin/nativelink.rs:677

  2024-07-13T05:38:08.879914Z  WARN nativelink_worker::local_worker: Worker registered with scheduler, worker_id: 8e0703dc-73c3-428f-a3c4-6dbebaafd0f7
    at nativelink-worker/src/local_worker.rs:558
    in nativelink::worker with name: "worker_0"

Json

$ NL_LOG=json cargo run --bin nativelink -- nativelink-config/examples/basic_cas.json
     Running `target/debug/nativelink nativelink-config/examples/basic_cas.json`
{"timestamp":"2024-07-13T05:38:25.159897Z","level":"WARN","fields":{"message":"Ready, listening on 0.0.0.0:50051"},"target":"nativelink"}
{"timestamp":"2024-07-13T05:38:25.160350Z","level":"WARN","fields":{"message":"Ready, listening on 0.0.0.0:50061"},"target":"nativelink"}
{"timestamp":"2024-07-13T05:38:25.164892Z","level":"WARN","fields":{"message":"Worker registered with scheduler","worker_id":"73cf46ea-c58c-480a-bf4f-bd792ced4f1d"},"target":"nativelink_worker::local_worker","span":{"name":"\"worker_0\"","name":"worker"},"spans":[{"name":"\"worker_0\"","name":"worker"}]}

compact

$ NL_LOG=compact cargo run --bin nativelink -- nativelink-config/examples/basic_cas.json
     Running `target/debug/nativelink nativelink-config/examples/basic_cas.json`
2024-07-13T05:38:34.098568Z  WARN nativelink: Ready, listening on 0.0.0.0:50051
2024-07-13T05:38:34.099017Z  WARN nativelink: Ready, listening on 0.0.0.0:50061
2024-07-13T05:38:34.104507Z  WARN worker: nativelink_worker::local_worker: Worker registered with scheduler worker_id=bf440d8a-8dab-4fe1-8683-1e40469b87c2 name="worker_0"

Checklist

  • bazel test //... passes locally
  • PR is contained in a single commit, using git amend see some docs

This change is Reviewable

`NL_LOG` envionment variable is used to control
the logging format that `tracing_subscriber`
emits out. We currently want to allow for better
ingestion of formatted logs in json.

`NL_LOG` can be configured with `pretty`, `json`,
or `compact`.
@adam-singer adam-singer requested a review from allada July 13, 2024 06:09
Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Analyze (javascript-typescript), Analyze (python), Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, Installation / macos-13, Installation / macos-14, Installation / ubuntu-22.04, Local / ubuntu-22.04, Publish image, Publish nativelink-worker-init, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, pre-commit-checks, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, windows-2022 / stable

@adam-singer adam-singer merged commit d9922b3 into TraceMachina:main Jul 13, 2024
29 checks passed
@adam-singer adam-singer deleted the adams/log-formatting-config branch July 13, 2024 06:58
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.

Introduce NL_LOG to control logging format
2 participants