pub fn create_utf8(logfile: &str) {
        // open file in write or append mode
        let log = File::create(&logfile).expect("unable to create fake logfile");
        let mut writer = BufWriter::new(&log);

        // initialize random seed
        let mut rng = thread_rng();

        // now write into our fake logfile
        let mut line_number = 0;

        for _ in 1..102 {
            line_number += 1;

            // insert ok pattern once
            if line_number == 51 {
                writeln!(
                    &mut writer,
                    "1970-01-01 00:00:00: ############# これはテスト用に生成された偽の OK パターンで、行番号 = {:03} です。",
                    line_number
                )
                .unwrap();
                continue;
            }

            // otherwise add error and warning lines
            let error_id: u32 = rng.gen_range(10000..=99999);
            writeln!(
                &mut writer,
                "1970-01-01 00:00:00: ---- これはテストに対して生成されたエラーで、行番号 = {:03}, エラー ID = {} です。",
                line_number, error_id
            ).unwrap();

            let warning_id: u32 = rng.gen_range(10000..=99999);
            line_number += 1;

            writeln!(
                &mut writer,
                "1970-01-01 00:00:00: * これはテストに対して生成された警告で、行番号 = {:03}、警告 ID = {} です。",
                line_number, warning_id
            )
            .unwrap();
        }
    }
// create a log with japanese utf8 chars
create a log with japanese utf8 chars
create a log with japanese utf8 chars
pub fn create_utf8(logfile: &str) {
        // open file in write or append mode
        let log = File::create(&logfile).expect("unable to create fake logfile");
        let mut writer = BufWriter::new(&log);
        // initialize random seed
        let mut rng = thread_rng();
        // now write into our fake logfile
        let mut line_number = 0;
        for _ in 1..102 {
            line_number += 1;
            // insert ok pattern once
            if line_number == 51 {
                writeln!(
                    &mut writer,
                    "1970-01-01 00:00:00: ############# これはテスト用に生成された偽の OK パターンで、行番号 = {:03} です。",
                    line_number
                )
                .unwrap();
                continue;
            }
            // otherwise add error and warning lines
            let error_id: u32 = rng.gen_range(10000..=99999);
            writeln!(
                &mut writer,
                "1970-01-01 00:00:00: ---- これはテストに対して生成されたエラーで、行番号 = {:03}, エラー ID = {} です。",
                line_number, error_id
            ).unwrap();
            let warning_id: u32 = rng.gen_range(10000..=99999);
            line_number += 1;
            writeln!(
                &mut writer,
                "1970-01-01 00:00:00: * これはテストに対して生成された警告で、行番号 = {:03}、警告 ID = {} です。",
                line_number, warning_id
            )
            .unwrap();
        }
    }
pub fn create_utf8 ( logfile : & str ) { // open file in write or append mode let log = File :: create ( & logfile ) . expect ( " " ) ; let mut writer = BufWriter :: new ( & log ) ; // initialize random seed let mut rng = thread_rng ( ) ; // now write into our fake logfile let mut line_number = 0 ; for _ in 1 .. 102 { line_number += 1 ; // insert ok pattern once if line_number == 51 { writeln ! ( mut writer " line_number ) . unwrap ( ) ; continue ; } // otherwise add error and warning lines let error_id : u32 = rng . gen_range ( 10000 ..= 99999 ) ; writeln ! ( mut writer " line_number error_id ) . unwrap ( ) ; let warning_id : u32 = rng . gen_range ( 10000 ..= 99999 ) ; line_number += 1 ; writeln ! ( mut writer " line_number warning_id ) . unwrap ( ) ; } }
create a log with japanese utf8 chars
create a log with japanese utf8 chars
logfile
&str
logfile
&str