Return an error from logging::initialize
Logging initialization now shares the same error handling code as the rest of the `run` function.
This commit is contained in:
parent
abd3958cb5
commit
ee37dc86ab
|
@ -53,9 +53,9 @@ impl<T: Send + io::Write> log::Log for Logger<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn initialize(options: &cli::Options) {
|
||||
pub fn initialize(options: &cli::Options) -> Result<(), log::SetLoggerError> {
|
||||
log::set_logger(|max_log_level| {
|
||||
max_log_level.set(options.log_level);
|
||||
Box::new(Logger::new(io::stdout(), options.log_level))
|
||||
}).unwrap_or_else(|e| die!("{}", e));
|
||||
})
|
||||
}
|
||||
|
|
|
@ -60,9 +60,6 @@ fn main() {
|
|||
// Load command line options
|
||||
let options = cli::Options::load();
|
||||
|
||||
// Initialize the logger before entering alacritty main loop
|
||||
logging::initialize(&options);
|
||||
|
||||
// Run alacritty
|
||||
if let Err(err) = run(config, options) {
|
||||
die!("Alacritty encountered an unrecoverable error:\n\n\t{}\n", Red(err));
|
||||
|
@ -77,6 +74,9 @@ fn main() {
|
|||
/// Creates a window, the terminal state, pty, I/O event loop, input processor,
|
||||
/// config change monitor, and runs the main display loop.
|
||||
fn run(mut config: Config, options: cli::Options) -> Result<(), Box<Error>> {
|
||||
// Initialize the logger first as to capture output from other subsystems
|
||||
logging::initialize(&options)?;
|
||||
|
||||
info!("Welcome to Alacritty.");
|
||||
|
||||
// Create a display.
|
||||
|
|
Loading…
Reference in New Issue