Fix osx rust build

This commit is contained in:
caesay
2024-01-03 22:24:13 +00:00
parent fdfcfe1160
commit c1c8e159fb
3 changed files with 21 additions and 18 deletions

View File

@@ -1,26 +1,10 @@
use anyhow::Result;
use simplelog::*;
use std::{env, path::PathBuf};
use std::path::PathBuf;
pub fn trace_logger() {
TermLogger::init(LevelFilter::Trace, Config::default(), TerminalMode::Mixed, ColorChoice::Never).unwrap();
}
pub fn default_logging(verbose: bool, nocolor: bool) -> Result<()> {
#[cfg(target_os = "windows")]
let default_log_file = {
let mut my_dir = env::current_exe().unwrap();
my_dir.pop();
my_dir.join("Velopack.log")
};
#[cfg(target_os = "macos")]
let default_log_file = {
let (_root, manifest) = shared::detect_current_manifest().expect("Unable to load app manfiest.");
std::path::Path::new(format!("/tmp/velopack/{}.log", manifest.id).as_str()).to_path_buf()
};
setup_logging(Some(&default_log_file), true, verbose, nocolor)
}
pub fn setup_logging(file: Option<&PathBuf>, console: bool, verbose: bool, nocolor: bool) -> Result<()> {
let mut loggers: Vec<Box<dyn SharedLogger>> = Vec::new();

View File

@@ -80,7 +80,7 @@ fn main() -> Result<()> {
if let Some(log_file) = log_file {
logging::setup_logging(Some(&log_file), true, verbose, nocolor)?;
} else {
logging::default_logging(verbose, nocolor)?;
default_logging(verbose, nocolor)?;
}
info!("Starting Velopack Updater ({})", env!("NGBV_VERSION"));
@@ -165,6 +165,23 @@ fn uninstall(_matches: &ArgMatches) -> Result<()> {
commands::uninstall(&root_path, &app, true)
}
pub fn default_logging(verbose: bool, nocolor: bool) -> Result<()> {
#[cfg(target_os = "windows")]
let default_log_file = {
let mut my_dir = env::current_exe().unwrap();
my_dir.pop();
my_dir.join("Velopack.log")
};
#[cfg(target_os = "macos")]
let default_log_file = {
let (_root, manifest) = shared::detect_current_manifest().expect("Unable to load app manfiest.");
std::path::Path::new(format!("/tmp/velopack/{}.log", manifest.id).as_str()).to_path_buf()
};
logging::setup_logging(Some(&default_log_file), true, verbose, nocolor)
}
#[cfg(target_os = "windows")]
#[test]
fn test_start_command_supports_legacy_commands() {

View File

@@ -1,3 +1,5 @@
#![allow(unused_imports)]
mod common;
use common::*;
use std::{fs, path::Path, path::PathBuf};