log: make verbose logging optional
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
use anyhow::{Ok, Result};
|
use anyhow::{Ok, Result};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
use android_logger::Config;
|
use android_logger::Config;
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
|
|
||||||
|
use crate::defs::KSUD_VERBOSE_LOG_FILE;
|
||||||
use crate::{apk_sign, assets, debug, defs, init_event, ksucalls, module, utils};
|
use crate::{apk_sign, assets, debug, defs, init_event, ksucalls, module, utils};
|
||||||
|
|
||||||
/// KernelSU userspace cli
|
/// KernelSU userspace cli
|
||||||
@@ -15,6 +16,9 @@ use crate::{apk_sign, assets, debug, defs, init_event, ksucalls, module, utils};
|
|||||||
struct Args {
|
struct Args {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Commands,
|
command: Commands,
|
||||||
|
|
||||||
|
#[arg(short, long, default_value_t = cfg!(debug_assertions))]
|
||||||
|
verbose: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Subcommand, Debug)]
|
#[derive(clap::Subcommand, Debug)]
|
||||||
@@ -281,6 +285,10 @@ pub fn run() -> Result<()> {
|
|||||||
|
|
||||||
let cli = Args::parse();
|
let cli = Args::parse();
|
||||||
|
|
||||||
|
if !cli.verbose && !Path::new(KSUD_VERBOSE_LOG_FILE).exists() {
|
||||||
|
log::set_max_level(LevelFilter::Info);
|
||||||
|
}
|
||||||
|
|
||||||
log::info!("command: {:?}", cli.command);
|
log::info!("command: {:?}", cli.command);
|
||||||
|
|
||||||
let result = match cli.command {
|
let result = match cli.command {
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ pub const MODULE_DIR: &str = concatcp!(ADB_DIR, "modules/");
|
|||||||
// warning: this directory should not change, or you need to change the code in module_installer.sh!!!
|
// warning: this directory should not change, or you need to change the code in module_installer.sh!!!
|
||||||
pub const MODULE_UPDATE_DIR: &str = concatcp!(ADB_DIR, "modules_update/");
|
pub const MODULE_UPDATE_DIR: &str = concatcp!(ADB_DIR, "modules_update/");
|
||||||
|
|
||||||
|
pub const KSUD_VERBOSE_LOG_FILE: &str = concatcp!(ADB_DIR, "verbose");
|
||||||
|
|
||||||
pub const TEMP_DIR: &str = "/debug_ramdisk";
|
pub const TEMP_DIR: &str = "/debug_ramdisk";
|
||||||
pub const MODULE_WEB_DIR: &str = "webroot";
|
pub const MODULE_WEB_DIR: &str = "webroot";
|
||||||
pub const MODULE_ACTION_SH: &str = "action.sh";
|
pub const MODULE_ACTION_SH: &str = "action.sh";
|
||||||
|
|||||||
Reference in New Issue
Block a user