feat(tvix/store): support RUST_LOG env var
This allows selectively increasing the log level for only parts of the stack. For example, the following RUST_LOG env var enables "tracing" level logging for `tvix_store` and `tvix_castore`, while keeping it at "info" for the rest of the stack: export RUST_LOG='info,tvix_store=trace,tvix_castore=trace' It only affects logs, not traces (if enabled). Change-Id: Ib936bd132a405f216e75c843db83fbd71d20a18a Reviewed-on: https://cl.tvl.fyi/c/depot/+/11182 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com>
This commit is contained in:
parent
82f8ce8b7d
commit
c0e16059e6
4 changed files with 153 additions and 20 deletions
38
tvix/Cargo.lock
generated
38
tvix/Cargo.lock
generated
|
@ -385,7 +385,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc"
|
checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex-automata",
|
"regex-automata 0.4.3",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1710,6 +1710,15 @@ dependencies = [
|
||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "matchers"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||||
|
dependencies = [
|
||||||
|
"regex-automata 0.1.10",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matchit"
|
name = "matchit"
|
||||||
version = "0.7.3"
|
version = "0.7.3"
|
||||||
|
@ -2291,7 +2300,7 @@ dependencies = [
|
||||||
"rand",
|
"rand",
|
||||||
"rand_chacha",
|
"rand_chacha",
|
||||||
"rand_xorshift",
|
"rand_xorshift",
|
||||||
"regex-syntax",
|
"regex-syntax 0.8.2",
|
||||||
"rusty-fork",
|
"rusty-fork",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"unarray",
|
"unarray",
|
||||||
|
@ -2532,8 +2541,17 @@ checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex-automata",
|
"regex-automata 0.4.3",
|
||||||
"regex-syntax",
|
"regex-syntax 0.8.2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.1.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||||
|
dependencies = [
|
||||||
|
"regex-syntax 0.6.29",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2544,9 +2562,15 @@ checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
"regex-syntax",
|
"regex-syntax 0.8.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.6.29"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
|
@ -3734,12 +3758,16 @@ version = "0.3.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
|
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"matchers",
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
|
"once_cell",
|
||||||
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sharded-slab",
|
"sharded-slab",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thread_local",
|
"thread_local",
|
||||||
|
"tracing",
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
"tracing-serde",
|
"tracing-serde",
|
||||||
|
|
105
tvix/Cargo.nix
105
tvix/Cargo.nix
|
@ -1333,7 +1333,7 @@ rec {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "regex-automata";
|
name = "regex-automata";
|
||||||
packageId = "regex-automata";
|
packageId = "regex-automata 0.4.3";
|
||||||
optional = true;
|
optional = true;
|
||||||
usesDefaultFeatures = false;
|
usesDefaultFeatures = false;
|
||||||
features = [ "dfa-search" ];
|
features = [ "dfa-search" ];
|
||||||
|
@ -5264,6 +5264,22 @@ rec {
|
||||||
};
|
};
|
||||||
resolvedDefaultFeatures = [ "default" "v5-04" "v5-05" "v5-10" "v5-13" "v5-20" "v5-21" "v5-22" "v5-23" "v5-25" "v5-27" "v5-32" "v5-35" "v5-38" ];
|
resolvedDefaultFeatures = [ "default" "v5-04" "v5-05" "v5-10" "v5-13" "v5-20" "v5-21" "v5-22" "v5-23" "v5-25" "v5-27" "v5-32" "v5-35" "v5-38" ];
|
||||||
};
|
};
|
||||||
|
"matchers" = rec {
|
||||||
|
crateName = "matchers";
|
||||||
|
version = "0.1.0";
|
||||||
|
edition = "2018";
|
||||||
|
sha256 = "0n2mbk7lg2vf962c8xwzdq96yrc9i0p8dbmm4wa1nnkcp1dhfqw2";
|
||||||
|
authors = [
|
||||||
|
"Eliza Weisman <eliza@buoyant.io>"
|
||||||
|
];
|
||||||
|
dependencies = [
|
||||||
|
{
|
||||||
|
name = "regex-automata";
|
||||||
|
packageId = "regex-automata 0.1.10";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
};
|
||||||
"matchit" = rec {
|
"matchit" = rec {
|
||||||
crateName = "matchit";
|
crateName = "matchit";
|
||||||
version = "0.7.3";
|
version = "0.7.3";
|
||||||
|
@ -7094,7 +7110,7 @@ rec {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "regex-syntax";
|
name = "regex-syntax";
|
||||||
packageId = "regex-syntax";
|
packageId = "regex-syntax 0.8.2";
|
||||||
optional = true;
|
optional = true;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -7777,13 +7793,13 @@ rec {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "regex-automata";
|
name = "regex-automata";
|
||||||
packageId = "regex-automata";
|
packageId = "regex-automata 0.4.3";
|
||||||
usesDefaultFeatures = false;
|
usesDefaultFeatures = false;
|
||||||
features = [ "alloc" "syntax" "meta" "nfa-pikevm" ];
|
features = [ "alloc" "syntax" "meta" "nfa-pikevm" ];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "regex-syntax";
|
name = "regex-syntax";
|
||||||
packageId = "regex-syntax";
|
packageId = "regex-syntax 0.8.2";
|
||||||
usesDefaultFeatures = false;
|
usesDefaultFeatures = false;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -7811,7 +7827,31 @@ rec {
|
||||||
};
|
};
|
||||||
resolvedDefaultFeatures = [ "default" "perf" "perf-backtrack" "perf-cache" "perf-dfa" "perf-inline" "perf-literal" "perf-onepass" "std" "unicode" "unicode-age" "unicode-bool" "unicode-case" "unicode-gencat" "unicode-perl" "unicode-script" "unicode-segment" ];
|
resolvedDefaultFeatures = [ "default" "perf" "perf-backtrack" "perf-cache" "perf-dfa" "perf-inline" "perf-literal" "perf-onepass" "std" "unicode" "unicode-age" "unicode-bool" "unicode-case" "unicode-gencat" "unicode-perl" "unicode-script" "unicode-segment" ];
|
||||||
};
|
};
|
||||||
"regex-automata" = rec {
|
"regex-automata 0.1.10" = rec {
|
||||||
|
crateName = "regex-automata";
|
||||||
|
version = "0.1.10";
|
||||||
|
edition = "2015";
|
||||||
|
sha256 = "0ci1hvbzhrfby5fdpf4ganhf7kla58acad9i1ff1p34dzdrhs8vc";
|
||||||
|
authors = [
|
||||||
|
"Andrew Gallant <jamslam@gmail.com>"
|
||||||
|
];
|
||||||
|
dependencies = [
|
||||||
|
{
|
||||||
|
name = "regex-syntax";
|
||||||
|
packageId = "regex-syntax 0.6.29";
|
||||||
|
optional = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
features = {
|
||||||
|
"default" = [ "std" ];
|
||||||
|
"fst" = [ "dep:fst" ];
|
||||||
|
"regex-syntax" = [ "dep:regex-syntax" ];
|
||||||
|
"std" = [ "regex-syntax" ];
|
||||||
|
"transducer" = [ "std" "fst" ];
|
||||||
|
};
|
||||||
|
resolvedDefaultFeatures = [ "default" "regex-syntax" "std" ];
|
||||||
|
};
|
||||||
|
"regex-automata 0.4.3" = rec {
|
||||||
crateName = "regex-automata";
|
crateName = "regex-automata";
|
||||||
version = "0.4.3";
|
version = "0.4.3";
|
||||||
edition = "2021";
|
edition = "2021";
|
||||||
|
@ -7835,7 +7875,7 @@ rec {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "regex-syntax";
|
name = "regex-syntax";
|
||||||
packageId = "regex-syntax";
|
packageId = "regex-syntax 0.8.2";
|
||||||
optional = true;
|
optional = true;
|
||||||
usesDefaultFeatures = false;
|
usesDefaultFeatures = false;
|
||||||
}
|
}
|
||||||
|
@ -7871,7 +7911,21 @@ rec {
|
||||||
};
|
};
|
||||||
resolvedDefaultFeatures = [ "alloc" "dfa-onepass" "dfa-search" "hybrid" "meta" "nfa-backtrack" "nfa-pikevm" "nfa-thompson" "perf-inline" "perf-literal" "perf-literal-multisubstring" "perf-literal-substring" "std" "syntax" "unicode" "unicode-age" "unicode-bool" "unicode-case" "unicode-gencat" "unicode-perl" "unicode-script" "unicode-segment" "unicode-word-boundary" ];
|
resolvedDefaultFeatures = [ "alloc" "dfa-onepass" "dfa-search" "hybrid" "meta" "nfa-backtrack" "nfa-pikevm" "nfa-thompson" "perf-inline" "perf-literal" "perf-literal-multisubstring" "perf-literal-substring" "std" "syntax" "unicode" "unicode-age" "unicode-bool" "unicode-case" "unicode-gencat" "unicode-perl" "unicode-script" "unicode-segment" "unicode-word-boundary" ];
|
||||||
};
|
};
|
||||||
"regex-syntax" = rec {
|
"regex-syntax 0.6.29" = rec {
|
||||||
|
crateName = "regex-syntax";
|
||||||
|
version = "0.6.29";
|
||||||
|
edition = "2018";
|
||||||
|
sha256 = "1qgj49vm6y3zn1hi09x91jvgkl2b1fiaq402skj83280ggfwcqpi";
|
||||||
|
authors = [
|
||||||
|
"The Rust Project Developers"
|
||||||
|
];
|
||||||
|
features = {
|
||||||
|
"default" = [ "unicode" ];
|
||||||
|
"unicode" = [ "unicode-age" "unicode-bool" "unicode-case" "unicode-gencat" "unicode-perl" "unicode-script" "unicode-segment" ];
|
||||||
|
};
|
||||||
|
resolvedDefaultFeatures = [ "default" "unicode" "unicode-age" "unicode-bool" "unicode-case" "unicode-gencat" "unicode-perl" "unicode-script" "unicode-segment" ];
|
||||||
|
};
|
||||||
|
"regex-syntax 0.8.2" = rec {
|
||||||
crateName = "regex-syntax";
|
crateName = "regex-syntax";
|
||||||
version = "0.8.2";
|
version = "0.8.2";
|
||||||
edition = "2021";
|
edition = "2021";
|
||||||
|
@ -11773,11 +11827,28 @@ rec {
|
||||||
"Tokio Contributors <team@tokio.rs>"
|
"Tokio Contributors <team@tokio.rs>"
|
||||||
];
|
];
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
{
|
||||||
|
name = "matchers";
|
||||||
|
packageId = "matchers";
|
||||||
|
optional = true;
|
||||||
|
}
|
||||||
{
|
{
|
||||||
name = "nu-ansi-term";
|
name = "nu-ansi-term";
|
||||||
packageId = "nu-ansi-term";
|
packageId = "nu-ansi-term";
|
||||||
optional = true;
|
optional = true;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
name = "once_cell";
|
||||||
|
packageId = "once_cell";
|
||||||
|
optional = true;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "regex";
|
||||||
|
packageId = "regex";
|
||||||
|
optional = true;
|
||||||
|
usesDefaultFeatures = false;
|
||||||
|
features = [ "std" "unicode-case" "unicode-perl" ];
|
||||||
|
}
|
||||||
{
|
{
|
||||||
name = "serde";
|
name = "serde";
|
||||||
packageId = "serde";
|
packageId = "serde";
|
||||||
|
@ -11803,6 +11874,12 @@ rec {
|
||||||
packageId = "thread_local";
|
packageId = "thread_local";
|
||||||
optional = true;
|
optional = true;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
name = "tracing";
|
||||||
|
packageId = "tracing";
|
||||||
|
optional = true;
|
||||||
|
usesDefaultFeatures = false;
|
||||||
|
}
|
||||||
{
|
{
|
||||||
name = "tracing-core";
|
name = "tracing-core";
|
||||||
packageId = "tracing-core";
|
packageId = "tracing-core";
|
||||||
|
@ -11822,6 +11899,16 @@ rec {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
devDependencies = [
|
devDependencies = [
|
||||||
|
{
|
||||||
|
name = "regex";
|
||||||
|
packageId = "regex";
|
||||||
|
usesDefaultFeatures = false;
|
||||||
|
features = [ "std" ];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "tracing";
|
||||||
|
packageId = "tracing";
|
||||||
|
}
|
||||||
{
|
{
|
||||||
name = "tracing-log";
|
name = "tracing-log";
|
||||||
packageId = "tracing-log";
|
packageId = "tracing-log";
|
||||||
|
@ -11855,7 +11942,7 @@ rec {
|
||||||
"valuable-serde" = [ "dep:valuable-serde" ];
|
"valuable-serde" = [ "dep:valuable-serde" ];
|
||||||
"valuable_crate" = [ "dep:valuable_crate" ];
|
"valuable_crate" = [ "dep:valuable_crate" ];
|
||||||
};
|
};
|
||||||
resolvedDefaultFeatures = [ "alloc" "ansi" "default" "fmt" "json" "nu-ansi-term" "registry" "serde" "serde_json" "sharded-slab" "smallvec" "std" "thread_local" "tracing-log" "tracing-serde" ];
|
resolvedDefaultFeatures = [ "alloc" "ansi" "default" "env-filter" "fmt" "json" "matchers" "nu-ansi-term" "once_cell" "regex" "registry" "serde" "serde_json" "sharded-slab" "smallvec" "std" "thread_local" "tracing" "tracing-log" "tracing-serde" ];
|
||||||
};
|
};
|
||||||
"try-lock" = rec {
|
"try-lock" = rec {
|
||||||
crateName = "try-lock";
|
crateName = "try-lock";
|
||||||
|
@ -12796,7 +12883,7 @@ rec {
|
||||||
{
|
{
|
||||||
name = "tracing-subscriber";
|
name = "tracing-subscriber";
|
||||||
packageId = "tracing-subscriber";
|
packageId = "tracing-subscriber";
|
||||||
features = [ "json" ];
|
features = [ "env-filter" "json" ];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "tvix-castore";
|
name = "tvix-castore";
|
||||||
|
|
|
@ -31,7 +31,7 @@ tonic = { version = "0.11.0", features = ["tls", "tls-roots"] }
|
||||||
tower = "0.4.13"
|
tower = "0.4.13"
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
tracing-opentelemetry = "0.22.0"
|
tracing-opentelemetry = "0.22.0"
|
||||||
tracing-subscriber = { version = "0.3.16", features = ["json"] }
|
tracing-subscriber = { version = "0.3.16", features = ["env-filter", "json"] }
|
||||||
tvix-castore = { path = "../castore" }
|
tvix-castore = { path = "../castore" }
|
||||||
url = "2.4.0"
|
url = "2.4.0"
|
||||||
walkdir = "2.4.0"
|
walkdir = "2.4.0"
|
||||||
|
|
|
@ -10,7 +10,8 @@ use tokio_listener::UserOptions;
|
||||||
use tonic::transport::Server;
|
use tonic::transport::Server;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
use tracing_subscriber::fmt::writer::MakeWriterExt;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
use tracing_subscriber::Layer;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
use tvix_castore::proto::blob_service_server::BlobServiceServer;
|
use tvix_castore::proto::blob_service_server::BlobServiceServer;
|
||||||
|
@ -55,6 +56,10 @@ struct Cli {
|
||||||
#[arg(long, default_missing_value = "true", default_value = "true", num_args(0..=1), require_equals(true), action(clap::ArgAction::Set))]
|
#[arg(long, default_missing_value = "true", default_value = "true", num_args(0..=1), require_equals(true), action(clap::ArgAction::Set))]
|
||||||
otlp: bool,
|
otlp: bool,
|
||||||
|
|
||||||
|
/// A global log level to use when printing logs.
|
||||||
|
/// It's also possible to set `RUST_LOG` according to
|
||||||
|
/// `tracing_subscriber::filter::EnvFilter`, which will always have
|
||||||
|
/// priority.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
log_level: Option<Level>,
|
log_level: Option<Level>,
|
||||||
|
|
||||||
|
@ -172,19 +177,32 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// configure log settings
|
// configure log settings
|
||||||
let level = cli.log_level.unwrap_or(Level::INFO);
|
let level = cli.log_level.unwrap_or(Level::INFO);
|
||||||
|
|
||||||
|
// Set up the tracing subscriber.
|
||||||
let subscriber = tracing_subscriber::registry()
|
let subscriber = tracing_subscriber::registry()
|
||||||
.with(
|
.with(
|
||||||
cli.json.then_some(
|
cli.json.then_some(
|
||||||
tracing_subscriber::fmt::Layer::new()
|
tracing_subscriber::fmt::Layer::new()
|
||||||
.with_writer(std::io::stderr.with_max_level(level))
|
.with_writer(std::io::stderr)
|
||||||
.json(),
|
.json()
|
||||||
|
.with_filter(
|
||||||
|
EnvFilter::builder()
|
||||||
|
.with_default_directive(level.into())
|
||||||
|
.from_env()
|
||||||
|
.expect("invalid RUST_LOG"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.with(
|
.with(
|
||||||
(!cli.json).then_some(
|
(!cli.json).then_some(
|
||||||
tracing_subscriber::fmt::Layer::new()
|
tracing_subscriber::fmt::Layer::new()
|
||||||
.with_writer(std::io::stderr.with_max_level(level))
|
.with_writer(std::io::stderr)
|
||||||
.pretty(),
|
.pretty()
|
||||||
|
.with_filter(
|
||||||
|
EnvFilter::builder()
|
||||||
|
.with_default_directive(level.into())
|
||||||
|
.from_env()
|
||||||
|
.expect("invalid RUST_LOG"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue