Start rebuilding with a cleanly-separated UI framework

This commit is contained in:
Nathan Sobo
2021-02-20 10:02:34 -07:00
commit b400449a58
13 changed files with 1863 additions and 0 deletions
+38
View File
@@ -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 }
}