Remove main file and add direnv configuration
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
// src/lib.rs
|
||||
//! Console logging utilities for Rust applications.
|
||||
|
||||
use log::{Level, LevelFilter, Metadata, Record, SetLoggerError};
|
||||
|
||||
/// A minimal console logger implementation.
|
||||
pub struct ConsoleLogger;
|
||||
|
||||
static LOGGER: ConsoleLogger = ConsoleLogger;
|
||||
|
||||
impl log::Log for ConsoleLogger {
|
||||
fn enabled(&self, metadata: &Metadata<'_>) -> bool {
|
||||
metadata.level() <= Level::Info
|
||||
}
|
||||
|
||||
fn log(&self, record: &Record<'_>) {
|
||||
if self.enabled(record.metadata()) {
|
||||
println!("[{}] {}", record.level(), record.args());
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&self) {}
|
||||
}
|
||||
|
||||
/// Initializes the console logger with `Info` as the maximum log level.
|
||||
pub fn init() -> Result<(), SetLoggerError> {
|
||||
log::set_logger(&LOGGER)?;
|
||||
log::set_max_level(LevelFilter::Info);
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
Reference in New Issue
Block a user