feat: v1.9.10

This commit is contained in:
2025-08-24 23:29:24 +08:00
parent 0ad8f83092
commit ff30fd42dd
4 changed files with 33 additions and 1 deletions

View File

@@ -111,7 +111,9 @@ impl TinyEncryptConfig {
"Parse config file: {}, failed: {}",
file
);
debugging!("Config: {:#?}", config);
let mut config = load_includes_and_merge(config);
debugging!("Final config: {:#?}", config);
if let Some(profiles) = config.profiles {
let mut splited_profiles = HashMap::new();
@@ -298,6 +300,7 @@ pub fn resolve_path_namespace(
}
pub fn load_includes_and_merge(mut config: TinyEncryptConfig) -> TinyEncryptConfig {
debugging!("Config includes: {:?}", &config.includes);
if let Some(includes) = &config.includes {
let sub_configs = search_include_configs(includes);
debugging!(

View File

@@ -35,6 +35,7 @@ pub use cmd_initpiv::init_piv;
pub use cmd_version::CmdVersion;
pub use cmd_version::version;
pub use config::TinyEncryptConfig;
pub use util_log::init_tiny_encrypt_log;
mod consts;
mod util;
@@ -75,4 +76,5 @@ mod util_keychainstatic;
mod cmd_execenv;
mod util_keychainkey;
mod util_simple_pbe;
mod util_log;

View File

@@ -11,7 +11,7 @@ use tiny_encrypt::CmdExecEnv;
use tiny_encrypt::CmdInitKeychain;
#[cfg(feature = "smartcard")]
use tiny_encrypt::CmdInitPiv;
use tiny_encrypt::{CmdConfig, CmdDirectDecrypt, CmdEncrypt, CmdInfo, CmdSimpleDecrypt, CmdSimpleEncrypt, CmdVersion};
use tiny_encrypt::{init_tiny_encrypt_log, CmdConfig, CmdDirectDecrypt, CmdEncrypt, CmdInfo, CmdSimpleDecrypt, CmdSimpleEncrypt, CmdVersion};
#[derive(Debug, Parser)]
#[command(name = "tiny-encrypt-rs")]
@@ -64,6 +64,8 @@ enum Commands {
}
fn main() -> XResult<()> {
init_tiny_encrypt_log();
let args = Cli::parse();
match args.command {
Commands::Encrypt(cmd_encrypt) => tiny_encrypt::encrypt(cmd_encrypt),

25
src/util_log.rs Normal file
View File

@@ -0,0 +1,25 @@
use rust_util::{util_env, util_msg, util_time};
use std::fs::File;
use std::io::Write;
use std::sync::mpsc::channel;
use std::{env, thread};
pub fn init_tiny_encrypt_log() {
if let Some(file_log) = util_env::env_var("TINY_ENCRYPT_FILE_LOG") {
let log_file_name = format!("{}-{}.log", file_log, util_time::get_current_millis());
if let Ok(mut log_file) = File::create(&log_file_name) {
env::set_var("LOGGER_LEVEL", "*"); // set logger to debug
log_file.write_all("Start logging...\n".as_bytes()).ok();
let (sender, receiver) = channel::<String>();
util_msg::set_logger_sender(sender);
thread::spawn(move || loop {
let m = match receiver.recv() {
Ok(msg) => format!("{}\n", msg),
Err(e) => format!("{}\n", e),
};
log_file.write_all(m.as_bytes()).ok();
});
}
}
}