Skip to content

Instantly share code, notes, and snippets.

@LnL7

LnL7/ofborg.log Secret

Created April 24, 2020 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LnL7/6ddac8f0b786d4c532b695ec333c7411 to your computer and use it in GitHub Desktop.
Save LnL7/6ddac8f0b786d4c532b695ec333c7411 to your computer and use it in GitHub Desktop.
Apr 24 22:56:20.659 INFO ofborg_simple_build: Loading config
Apr 24 22:56:20.660 INFO ofborg_simple_build: Running build
Apr 24 22:56:20.660 DEBUG ofborg::nix: running build file=DefaultNixpkgs attrs=["hello"]
diff --git a/ofborg-simple-build/src/main.rs b/ofborg-simple-build/src/main.rs
index 6583c77..6772bf5 100644
--- a/ofborg-simple-build/src/main.rs
+++ b/ofborg-simple-build/src/main.rs
@@ -1,6 +1,3 @@
-#[macro_use]
-extern crate log;
-
use std::env;
use std::fs::File;
use std::io::Read;
@@ -10,13 +7,14 @@ use ofborg::config;
use ofborg::nix;
fn main() {
- ofborg::setup_log();
+ env::set_var("RUST_LOG", "debug");
+ tracing_subscriber::fmt::init();
- log::info!("Loading config...");
+ tracing::info!("Loading config");
let cfg = config::load(env::args().nth(1).unwrap().as_ref());
let nix = cfg.nix();
- log::info!("Running build...");
+ tracing::info!("Running build");
match nix.safely_build_attrs(
&Path::new("./"),
nix::File::DefaultNixpkgs,
diff --git a/ofborg/src/nix.rs b/ofborg/src/nix.rs
index e0bb21a..a4517b0 100644
--- a/ofborg/src/nix.rs
+++ b/ofborg/src/nix.rs
@@ -2,6 +2,7 @@ use crate::asynccmd::{AsyncCmd, SpawnedAsyncCmd};
use crate::ofborg::partition_result;
use tempfile::tempfile;
+use tracing::{event, Level};
use std::collections::HashMap;
use std::env;
@@ -192,6 +193,7 @@ impl Nix {
attrs: Vec<String>,
) -> Result<fs::File, fs::File> {
let mut command = self.safe_command::<&OsStr>(&Operation::Build, nixpkgs, &[], &[]);
+ event!(Level::DEBUG, ?file, ?attrs, "running build");
self.set_attrs_command(&mut command, file, attrs);
self.run(command, true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment