Skip to content

Commit

Permalink
wip: commit changes
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
sandydoo committed Oct 30, 2024
1 parent e827eee commit fac3f42
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 226 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ tempdir = "0.3.7"
tempfile = "3.12.0"
thiserror = "1.0.63"
tracing = "0.1.40"
tracing-core = "0.1.32"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tokio = { version = "1.39.3", features = [
"process",
Expand Down
1 change: 0 additions & 1 deletion devenv-eval-cache/src/internal_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ mod test {
msg: "\u{1b}[31;1merror:\u{1b}[0m\nsomething went wrong".to_string(),
raw_msg: None,
};
eprintln!("{:?}", log);
assert!(log.is_nix_error());
}

Expand Down
2 changes: 1 addition & 1 deletion devenv-tasks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ impl Tasks {
while let Some(res) = running_tasks.join_next().await {
match res {
Ok(_) => (),
Err(e) => eprintln!("Task crashed: {}", e),
Err(e) => error!("Task crashed: {}", e),
}
}

Expand Down
2 changes: 1 addition & 1 deletion devenv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ tempfile.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-core.workspace = true
tracing-subscriber.workspace = true
which.workspace = true
whoami.workspace = true
xdg.workspace = true
tracing-core = "0.1.32"
3 changes: 2 additions & 1 deletion devenv/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use clap::{crate_version, Parser, Subcommand};
use std::path::PathBuf;
use tracing::error;

#[derive(Parser)]
#[command(
Expand Down Expand Up @@ -348,7 +349,7 @@ pub fn default_system() -> String {

fn max_jobs() -> u8 {
let num_cpus = std::thread::available_parallelism().unwrap_or_else(|e| {
eprintln!("Failed to get number of logical CPUs: {}", e);
error!("Failed to get number of logical CPUs: {}", e);
std::num::NonZeroUsize::new(1).unwrap()
});
(num_cpus.get() / 2).try_into().unwrap()
Expand Down
9 changes: 4 additions & 5 deletions devenv/src/cnix.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{cli, config, log};
use crate::{cli, config};
use miette::{bail, IntoDiagnostic, Result, WrapErr};
use serde::Deserialize;
use sqlx::SqlitePool;
Expand All @@ -11,7 +11,7 @@ use std::os::unix::process::CommandExt;
use std::path::{Path, PathBuf};
use std::process;
use std::time::{SystemTime, UNIX_EPOCH};
use tracing::{debug, error, info, warn, Level};
use tracing::{debug, error, info, warn};

pub struct Nix<'a> {
pub options: Options<'a>,
Expand Down Expand Up @@ -364,7 +364,7 @@ impl<'a> Nix<'a> {

cached_cmd.on_stderr(move |log| {
if let Some(msg) = log.get_log_msg_by_level(target_log_level) {
eprintln!("{msg}");
info!("{msg}");
}
});
}
Expand Down Expand Up @@ -392,9 +392,8 @@ impl<'a> Nix<'a> {
None => "without exit code".to_string(),
};
if options.logging {
eprintln!();
error!(
"Command produced the following output:\n{}\n{}",
"\nCommand produced the following output:\n{}\n{}",
String::from_utf8_lossy(&result.stdout),
String::from_utf8_lossy(&result.stderr),
);
Expand Down
4 changes: 2 additions & 2 deletions devenv/src/devenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{
fs,
path::{Path, PathBuf},
};
use tracing::{debug, error, info, warn, Instrument, Level};
use tracing::{debug, error, info, warn, Instrument};

// templates
const FLAKE_TMPL: &str = include_str!("flake.tmpl.nix");
Expand Down Expand Up @@ -819,7 +819,7 @@ impl Devenv {

let gc_root = self.devenv_dot_gc.join("shell");
let span = tracing::info_span!("building_shell", user_message = "Building shell");
let env = { self.nix.dev_env(json, &gc_root).instrument(span).await? };
let env = self.nix.dev_env(json, &gc_root).instrument(span).await?;

std::fs::write(
self.devenv_dotfile.join("input-paths.txt"),
Expand Down
Loading

0 comments on commit fac3f42

Please sign in to comment.