summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2025-01-14 20:38:26 -0600
committerLibravatar bigfoot547 <[email protected]>2025-01-14 20:38:26 -0600
commitb833fbff8e24b56a1587b0115ee4332627d38ec2 (patch)
tree85349165b33339c0eb33c0e13a783cbcb26f02c4
parentadd logger config stuffs (diff)
fix stuff
-rw-r--r--Cargo.lock5
-rw-r--r--ozone-cli/Cargo.toml1
-rw-r--r--ozone-cli/src/main.rs11
-rw-r--r--src/launcher.rs14
4 files changed, 23 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8849ddd..a5cc39c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2154,9 +2154,9 @@ dependencies = [
[[package]]
name = "log"
-version = "0.4.22"
+version = "0.4.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
+checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
[[package]]
name = "lru"
@@ -2732,6 +2732,7 @@ dependencies = [
name = "ozone-cli"
version = "0.1.0"
dependencies = [
+ "log",
"o3launcher",
"simple_logger",
"sysinfo",
diff --git a/ozone-cli/Cargo.toml b/ozone-cli/Cargo.toml
index e60a539..bdcec85 100644
--- a/ozone-cli/Cargo.toml
+++ b/ozone-cli/Cargo.toml
@@ -8,3 +8,4 @@ sysinfo = { version = "0.33.1", features = ["system", "multithread"] }
o3launcher = { path = ".." }
tokio = { version = "1.43.0", features = ["rt", "rt-multi-thread", "macros"] }
simple_logger = { version = "5.0.0", features = ["colors"] }
+log = "0.4.25"
diff --git a/ozone-cli/src/main.rs b/ozone-cli/src/main.rs
index 67932da..d14d2a1 100644
--- a/ozone-cli/src/main.rs
+++ b/ozone-cli/src/main.rs
@@ -1,16 +1,17 @@
use std::env::consts::{ARCH, OS};
use std::error::Error;
use std::path::PathBuf;
+use log::info;
use sysinfo::System;
use o3launcher::launcher::Profile;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
- simple_logger::SimpleLogger::new().init().unwrap();
+ simple_logger::SimpleLogger::new().env().init().unwrap();
- println!("Hello, world!");
- println!("stuff: {:?} {:?} {:?} {:?} {:?}", System::name(), System::os_version(), System::long_os_version(), System::kernel_version(), System::cpu_arch());
- println!("stuff: {:?} {:?} {:?} {}", System::distribution_id(), OS, ARCH, size_of::<*const i32>());
+ info!("Hello, world!");
+ info!("stuff: {:?} {:?} {:?} {:?} {:?}", System::name(), System::os_version(), System::long_os_version(), System::kernel_version(), System::cpu_arch());
+ info!("stuff: {:?} {:?} {:?} {}", System::distribution_id(), OS, ARCH, size_of::<*const i32>());
let launcher = o3launcher::launcher::Launcher::new(PathBuf::from("./work").as_path(), true).await?;
let profile = Profile {
@@ -19,7 +20,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
instance: "".into()
};
launcher.prepare_launch(&profile).await?;
- println!("ok");
+ info!("ok");
Ok(())
}
diff --git a/src/launcher.rs b/src/launcher.rs
index 03b289d..96ba3bd 100644
--- a/src/launcher.rs
+++ b/src/launcher.rs
@@ -244,6 +244,8 @@ impl Launcher {
path.push(filename);
+ debug!("Logger config {} is at {}", id, path.display());
+
// creates the JVM argument for this logger config
fn get_arg(arg: &str, path: &Path) -> String {
strsub::replace_str(arg, |key| match key {
@@ -255,7 +257,10 @@ impl Launcher {
// verify the file
match util::verify_file(path.as_path(), dlinfo.size, dlinfo.sha1).await {
// integrity passed. return
- Ok(_) => return Ok(Some(get_arg(config.client.argument.as_str(), path.as_path()))),
+ Ok(_) => {
+ info!("Log configuration {} exists and integrity matches. Skipping.", id);
+ return Ok(Some(get_arg(config.client.argument.as_str(), path.as_path())));
+ },
// ruh roh
Err(e) => match e {
@@ -283,6 +288,8 @@ impl Launcher {
error: e
})?;
+ debug!("Logger configuration {} must be downloaded ({}).", id, url);
+
let mut response = reqwest::get(url).await.map_err(|e| LogConfigError::Download{ url: url.to_owned(), error: e })?;
let mut tally = 0usize;
let mut sha1 = Sha1::new();
@@ -302,6 +309,7 @@ impl Launcher {
drop(file); // manually close file
let del_file_silent = || async {
+ debug!("Deleting downloaded log config {} since its integrity doesn't match :( {}", id, path.display());
let _ = fs::remove_file(path.as_path()).await.map_err(|e| warn!("failed to delete invalid log config: {}", e));
()
};
@@ -326,6 +334,8 @@ impl Launcher {
}));
}
+ info!("Log configuration {} downloaded successfully.", id);
+
Ok(Some(get_arg(config.client.argument.as_str(), path.as_path())))
}
@@ -414,6 +424,8 @@ impl Launcher {
} else {
log_arg = None;
}
+
+ dbg!(log_arg);
//todo!()
Ok(())