loggur 0.1.0

로깅 크레이트
Documentation
use loggur::{Loggur, Level, info, progress_span, progress_inc};
use std::thread;
use std::time::Duration;

fn main() {
    // tracing과 indicatif 통합 로거 초기화
    Loggur::init_with_progress(Level::INFO);
    
    info!("진행 상태 표시 예제를 시작합니다");
    
    // 기본 진행 상태 표시줄
    {
        let total = 50;
        let span = progress_span!("기본 진행 상태 표시줄", total);
        let _enter = span.enter();
        
        for _ in 0..total {
            // 작업 시뮬레이션
            thread::sleep(Duration::from_millis(50));
            progress_inc!(1);
        }
    }
    
    info!("기본 진행 상태 표시줄 완료!");
    
    // 스피너 스타일 진행 상태 표시
    {
        let spinner = Loggur::spinner();
        
        for i in 0..10 {
            // 작업 시뮬레이션
            thread::sleep(Duration::from_millis(200));
            spinner.set_message(format!("작업 처리 중... 단계 {}/10", i + 1));
        }
        
        spinner.finish_with_message("스피너 작업 완료!");
    }
    
    // 여러 진행 상태 표시줄 동시에 사용
    {
        let parent_span = progress_span!("멀티 작업", 3);
        let _parent_enter = parent_span.enter();
        
        let handles = (0..3).map(|task_id| {
            let task_items = match task_id {
                0 => 30,
                1 => 50,
                _ => 20,
            };
            
            thread::spawn(move || {
                // 각 작업마다 별도의 span 생성
                let span = progress_span!(concat!("작업 ", "{task_id}"), task_items);
                let _enter = span.enter();
                
                for _ in 0..task_items {
                    thread::sleep(Duration::from_millis(match task_id {
                        0 => 50,
                        1 => 30,
                        _ => 70,
                    }));
                    progress_inc!(1);
                }
                
                info!("작업 {} 완료!", task_id + 1);
            })
        }).collect::<Vec<_>>();
        
        // 모든 스레드가 완료될 때까지 대기
        for handle in handles {
            handle.join().unwrap();
        }
        
        // 부모 작업 진행 상태 업데이트
        progress_inc!(3);
    }
    
    info!("모든 진행 상태 표시 예제가 완료되었습니다");
}