feat(users/picnoir/tvix-daemon): add log verbosity flag
Adding a verbosity flag available through the CLI/ENV variable. Change-Id: If04cc2e6e26e7cb3c2df7821fce222da2b85a95a Reviewed-on: https://cl.tvl.fyi/c/depot/+/11349 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
9cec50cb2e
commit
32724d28ee
3 changed files with 18 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
||||||
# This file was @generated by crate2nix 0.13.0 with the command:
|
# This file was @generated by crate2nix 0.12.0 with the command:
|
||||||
# "generate" "--all-features"
|
# "generate"
|
||||||
# See https://github.com/kolloch/crate2nix for more info.
|
# See https://github.com/kolloch/crate2nix for more info.
|
||||||
|
|
||||||
{ nixpkgs ? <nixpkgs>
|
{ nixpkgs ? <nixpkgs>
|
||||||
|
@ -825,7 +825,7 @@ rec {
|
||||||
"usage" = [ "clap_builder/usage" ];
|
"usage" = [ "clap_builder/usage" ];
|
||||||
"wrap_help" = [ "clap_builder/wrap_help" ];
|
"wrap_help" = [ "clap_builder/wrap_help" ];
|
||||||
};
|
};
|
||||||
resolvedDefaultFeatures = [ "color" "default" "derive" "error-context" "help" "std" "suggestions" "usage" ];
|
resolvedDefaultFeatures = [ "color" "default" "derive" "env" "error-context" "help" "std" "suggestions" "usage" ];
|
||||||
};
|
};
|
||||||
"clap_builder" = rec {
|
"clap_builder" = rec {
|
||||||
crateName = "clap_builder";
|
crateName = "clap_builder";
|
||||||
|
@ -864,7 +864,7 @@ rec {
|
||||||
"unstable-v5" = [ "deprecated" ];
|
"unstable-v5" = [ "deprecated" ];
|
||||||
"wrap_help" = [ "help" "dep:terminal_size" ];
|
"wrap_help" = [ "help" "dep:terminal_size" ];
|
||||||
};
|
};
|
||||||
resolvedDefaultFeatures = [ "color" "error-context" "help" "std" "suggestions" "usage" ];
|
resolvedDefaultFeatures = [ "color" "env" "error-context" "help" "std" "suggestions" "usage" ];
|
||||||
};
|
};
|
||||||
"clap_derive" = rec {
|
"clap_derive" = rec {
|
||||||
crateName = "clap_derive";
|
crateName = "clap_derive";
|
||||||
|
@ -4160,7 +4160,7 @@ rec {
|
||||||
{
|
{
|
||||||
name = "clap";
|
name = "clap";
|
||||||
packageId = "clap";
|
packageId = "clap";
|
||||||
features = [ "derive" ];
|
features = [ "derive" "env" ];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "nix-compat";
|
name = "nix-compat";
|
||||||
|
@ -5205,7 +5205,6 @@ rec {
|
||||||
(
|
(
|
||||||
_: {
|
_: {
|
||||||
buildTests = true;
|
buildTests = true;
|
||||||
release = false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
# If the user hasn't set any pre/post commands, we don't want to
|
# If the user hasn't set any pre/post commands, we don't want to
|
||||||
|
@ -5230,16 +5229,6 @@ rec {
|
||||||
# recreate a file hierarchy as when running tests with cargo
|
# recreate a file hierarchy as when running tests with cargo
|
||||||
|
|
||||||
# the source for test data
|
# the source for test data
|
||||||
# It's necessary to locate the source in $NIX_BUILD_TOP/source/
|
|
||||||
# instead of $NIX_BUILD_TOP/
|
|
||||||
# because we compiled those test binaries in the former and not the latter.
|
|
||||||
# So all paths will expect source tree to be there and not in the build top directly.
|
|
||||||
# For example: $NIX_BUILD_TOP := /build in general, if you ask yourself.
|
|
||||||
# TODO(raitobezarius): I believe there could be more edge cases if `crate.sourceRoot`
|
|
||||||
# do exist but it's very hard to reason about them, so let's wait until the first bug report.
|
|
||||||
mkdir -p source/
|
|
||||||
cd source/
|
|
||||||
|
|
||||||
${pkgs.buildPackages.xorg.lndir}/bin/lndir ${crate.src}
|
${pkgs.buildPackages.xorg.lndir}/bin/lndir ${crate.src}
|
||||||
|
|
||||||
# build outputs
|
# build outputs
|
||||||
|
|
|
@ -10,7 +10,7 @@ tokio = { version = "1.36.0", features = ["full"] }
|
||||||
tracing-subscriber = "0.3.18"
|
tracing-subscriber = "0.3.18"
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
anyhow = "1.0.81"
|
anyhow = "1.0.81"
|
||||||
clap = { version = "4.5.3", features = ["derive"] }
|
clap = { version = "4.5.3", features = ["derive", "env"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio-test = "0.4.4"
|
tokio-test = "0.4.4"
|
||||||
|
|
|
@ -2,7 +2,7 @@ use anyhow::anyhow;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio_listener::{self, SystemOptions, UserOptions};
|
use tokio_listener::{self, SystemOptions, UserOptions};
|
||||||
use tracing::{debug, error, info, instrument};
|
use tracing::{debug, error, info, instrument, Level};
|
||||||
|
|
||||||
use nix_compat::wire::{bytes, primitive, worker_protocol};
|
use nix_compat::wire::{bytes, primitive, worker_protocol};
|
||||||
|
|
||||||
|
@ -11,14 +11,23 @@ struct Cli {
|
||||||
/// Listening unix socket path
|
/// Listening unix socket path
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
socket: Option<String>,
|
socket: Option<String>,
|
||||||
|
/// Log verbosity level. Can be "error", "warn", "info", "debug", "trace", or a number 1-5
|
||||||
|
#[arg(short, long, env)]
|
||||||
|
verbosity: Option<Level>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
#[instrument()]
|
#[instrument()]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
tracing_subscriber::fmt().compact().try_init().unwrap();
|
|
||||||
let args = Cli::parse();
|
let args = Cli::parse();
|
||||||
|
tracing_subscriber::fmt()
|
||||||
|
.compact()
|
||||||
|
.with_max_level(
|
||||||
|
args.verbosity
|
||||||
|
.unwrap_or_else(|| panic!("Can't parse log verbosity")),
|
||||||
|
)
|
||||||
|
.try_init()
|
||||||
|
.unwrap();
|
||||||
info!("Started Tvix daemon");
|
info!("Started Tvix daemon");
|
||||||
let addr = args
|
let addr = args
|
||||||
.socket
|
.socket
|
||||||
|
|
Loading…
Reference in a new issue