mirror of
https://github.com/bytedream/docker4ssh.git
synced 2025-06-27 09:50:31 +02:00
Initial commit
This commit is contained in:
19
container/src/shared/logging/logger.rs
Normal file
19
container/src/shared/logging/logger.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use log::{info, Metadata, Record};
|
||||
|
||||
pub struct Logger;
|
||||
|
||||
impl log::Log for Logger {
|
||||
fn enabled(&self, metadata: &Metadata) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn log(&self, record: &Record) {
|
||||
if self.enabled(record.metadata()) {
|
||||
println!("{}", record.args().to_string())
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&self) {
|
||||
todo!()
|
||||
}
|
||||
}
|
11
container/src/shared/logging/mod.rs
Normal file
11
container/src/shared/logging/mod.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use log::{LevelFilter, SetLoggerError};
|
||||
|
||||
pub mod logger;
|
||||
|
||||
pub use logger::Logger;
|
||||
|
||||
static LOGGER: Logger = Logger;
|
||||
|
||||
pub fn init_logger(level: LevelFilter) -> Result<(), SetLoggerError> {
|
||||
log::set_logger(&Logger).map(|()| log::set_max_level(level))
|
||||
}
|
Reference in New Issue
Block a user