Start rebuilding with a cleanly-separated UI framework
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
use std::fs;
|
||||
|
||||
use fs::OpenOptions;
|
||||
use gpui::platform::{current as platform, App as _};
|
||||
use log::LevelFilter;
|
||||
use simplelog::SimpleLogger;
|
||||
|
||||
fn main() {
|
||||
init_logger();
|
||||
platform::app()
|
||||
.on_finish_launching(|| log::info!("finish launching"))
|
||||
.run();
|
||||
}
|
||||
|
||||
fn init_logger() {
|
||||
let level = LevelFilter::Info;
|
||||
|
||||
if stdout_is_a_pty() {
|
||||
SimpleLogger::init(level, Default::default()).expect("could not initialize logger");
|
||||
} else {
|
||||
let log_dir_path = dirs::home_dir()
|
||||
.expect("could not locate home directory for logging")
|
||||
.join("Library/Logs/");
|
||||
let log_file_path = log_dir_path.join("Zed.log");
|
||||
fs::create_dir_all(&log_dir_path).expect("could not create log directory");
|
||||
let log_file = OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(log_file_path)
|
||||
.expect("could not open logfile");
|
||||
simplelog::WriteLogger::init(level, simplelog::Config::default(), log_file)
|
||||
.expect("could not initialize logger");
|
||||
}
|
||||
}
|
||||
|
||||
fn stdout_is_a_pty() -> bool {
|
||||
unsafe { libc::isatty(libc::STDOUT_FILENO as i32) != 0 }
|
||||
}
|
||||
Reference in New Issue
Block a user