Created
July 1, 2023 17:10
-
-
Save timelessnesses/c2a950a9f38dd84abd81562d7b8ad849 to your computer and use it in GitHub Desktop.
I laughed at this
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std; | |
use log; | |
use env_logger; | |
struct CustomTargetAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA{ | |
file: std::fs::File | |
} | |
impl CustomTargetAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA { | |
fn new() -> Result<CustomTargetAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, std::io::Error> { | |
let x = std::fs::File::create("log.txt"); | |
match x { | |
Ok(f) => return Ok(CustomTargetAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA {file: f}), | |
Err(e) => { | |
log::warn!("Cannot create log file."); | |
return Err(e); | |
} | |
} | |
} | |
} | |
impl std::io::Write for CustomTargetAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA { | |
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { | |
let _ = std::io::stdout().write(buf); | |
self.file.write(buf) | |
} | |
fn flush(&mut self) -> std::io::Result<()> { | |
match std::io::stdout().flush() { | |
Err(e) => return Err(e), | |
Ok(_) => { | |
match self.file.flush() { | |
Ok(_) => return Ok(()), | |
Err(e) => return Err(e) | |
} | |
} | |
} | |
} | |
} | |
fn config_logger() { | |
let mut b = env_logger::Builder::from_default_env(); | |
b.filter_level(log::LevelFilter::Debug); | |
b.target(env_logger::Target::Stdout); | |
let x = CustomTargetAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA::new(); | |
match x { | |
Ok(file_info) => { | |
b.target(env_logger::Target::Pipe(Box::new(file_info))); | |
}, | |
Err(e) => { | |
log::warn!("{}",format!("Logger cannot create or write to log.txt. {}", e)); | |
} | |
} | |
b.init(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment