MCPcopy Create free account
hub / github.com/VSCodeConfigHelper/v4 / setup

Function setup

src-tauri/src/log.rs:46–81  ·  view source on GitHub ↗
(path: Option<&String>, log_level: log::LevelFilter)

Source from the content-addressed store, hash-verified

44}
45
46pub fn setup(path: Option<&String>, log_level: log::LevelFilter) -> Result<()> {
47 *LOG_PATH.lock().unwrap() = path.map(|s| PathBuf::from(s));
48 fern::Dispatch::new()
49 .chain(
50 fern::Dispatch::new()
51 .level(log::LevelFilter::Trace)
52 .format(|out, message, record| {
53 out.finish(format_args!(
54 "{}[{}][{}] {}",
55 chrono::Local::now().format("[%Y-%m-%d %H:%M:%S]"),
56 record.target(),
57 record.level(),
58 message
59 ))
60 })
61 .chain(fs::File::create(get_log_path())?),
62 )
63 .chain(
64 fern::Dispatch::new()
65 .level(log_level)
66 .format(|out, message, record| {
67 out.finish(format_args!(
68 "[{}] {}",
69 ColoredLevelConfig::new().color(record.level()),
70 message
71 ))
72 })
73 .chain(std::io::stdout()),
74 )
75 .apply()?;
76
77 info!("版本 v{}", env!("CARGO_PKG_VERSION"));
78 info!("操作系统 {}", os_info::get());
79 info!("处理器 {}", std::env::consts::ARCH);
80 Ok(())
81}

Callers

nothing calls this directly

Calls 2

createFunction · 0.85
get_log_pathFunction · 0.85

Tested by

no test coverage detected