From 005156915c9d1d36500b73b9c44d9179aecd8c2f Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 23 Mar 2021 18:55:49 +0530 Subject: add logger --- src/main.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 197b200..1f5dc8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,11 +17,28 @@ use std::{ io::{Cursor, Read}, }; +use log::{error, info}; use obi::Image; pub fn main() { - let sdl_context = sdl2::init().unwrap(); - let ttf_context = sdl2::ttf::init().unwrap(); + env_logger::init(); + + let sdl_context = sdl2::init(); + if sdl_context.is_err() { + error!("Unable to find libsdl2 ... Exiting"); + return; + } + let sdl_context = sdl_context.unwrap(); + info!("Initialized SDL context"); + + let ttf_context = sdl2::ttf::init(); + if ttf_context.is_err() { + error!("Unable to find SDL2_ttf ... Exiting"); + return; + } + let ttf_context = ttf_context.unwrap(); + info!("Initialized SDL_ttf context"); + let args: Vec<_> = env::args().collect(); if args.len() < 2 { AppState::init(160, 160, &sdl_context, &ttf_context, None).run(); -- cgit v1.2.3