mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Add custom rust log callback param
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2309,6 +2309,7 @@ dependencies = [
|
||||
"neon",
|
||||
"semver",
|
||||
"serde_json",
|
||||
"simplelog",
|
||||
"ts-rs",
|
||||
"velopack",
|
||||
]
|
||||
|
||||
@@ -79,7 +79,7 @@ fn main_inner() -> Result<()> {
|
||||
|
||||
let verbose = matches.get_flag("verbose");
|
||||
let logfile = matches.get_one::<PathBuf>("log");
|
||||
velopack::logging::init_logging("setup", logfile, true, verbose);
|
||||
velopack::logging::init_logging("setup", logfile, true, verbose, None);
|
||||
|
||||
let debug = matches.get_one::<PathBuf>("debug");
|
||||
let install_to = matches.get_one::<PathBuf>("installto");
|
||||
|
||||
@@ -19,7 +19,7 @@ fn main() -> ExitCode {
|
||||
my_dir.join("Velopack.log")
|
||||
};
|
||||
|
||||
let _ = velopack::logging::init_logging("stub", Some(&default_log_file), false, false);
|
||||
let _ = velopack::logging::init_logging("stub", Some(&default_log_file), false, false, None);
|
||||
|
||||
info!("--");
|
||||
info!("Starting Velopack Stub (at {:?})", my_path);
|
||||
|
||||
@@ -134,7 +134,7 @@ fn main() -> Result<()> {
|
||||
let verbose = get_flag_or_false(&matches, "verbose");
|
||||
let log_file = matches.get_one("log");
|
||||
let desired_log_file = log_file.cloned().unwrap_or(default_logfile_path(LocationContext::IAmUpdateExe));
|
||||
init_logging("update", Some(&desired_log_file), true, verbose);
|
||||
init_logging("update", Some(&desired_log_file), true, verbose, None);
|
||||
|
||||
// change working directory to the parent directory of the exe
|
||||
let mut containing_dir = env::current_exe()?;
|
||||
|
||||
@@ -76,8 +76,12 @@ pub fn default_logfile_path<L: TryInto<VelopackLocator>>(locator: L) -> PathBuf
|
||||
/// It can only be called once per process, and should be called early in the process lifecycle.
|
||||
/// Future calls to this function will fail.
|
||||
#[cfg(feature = "file-logging")]
|
||||
pub fn init_logging(process_name: &str, file: Option<&PathBuf>, console: bool, verbose: bool) {
|
||||
pub fn init_logging(process_name: &str, file: Option<&PathBuf>, console: bool, verbose: bool, custom_log_cb: Option<Box<dyn SharedLogger>>) {
|
||||
let mut loggers: Vec<Box<dyn SharedLogger>> = Vec::new();
|
||||
if let Some(cb) = custom_log_cb {
|
||||
loggers.push(cb);
|
||||
}
|
||||
|
||||
let color_choice = ColorChoice::Never;
|
||||
if console {
|
||||
let console_level = if verbose { LevelFilter::Debug } else { LevelFilter::Info };
|
||||
|
||||
Reference in New Issue
Block a user