Write logger
This commit is contained in:
parent
6a32f160b7
commit
6cfa4c357e
7
logger/Cargo.lock
generated
Normal file
7
logger/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "logger"
|
||||
version = "0.1.0"
|
6
logger/Cargo.toml
Normal file
6
logger/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "logger"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
34
logger/src/main.rs
Normal file
34
logger/src/main.rs
Normal file
@ -0,0 +1,34 @@
|
||||
pub trait Logger {
|
||||
/// Log a message at the given verbosity level.
|
||||
fn log(&self, verbosity: u8, message: &str);
|
||||
}
|
||||
|
||||
struct StdoutLogger;
|
||||
|
||||
impl Logger for StdoutLogger {
|
||||
fn log(&self, verbosity: u8, message: &str) {
|
||||
println!("verbosity={verbosity}: {message}");
|
||||
}
|
||||
}
|
||||
|
||||
struct VerbosityFilter {
|
||||
max_verbosity: u8,
|
||||
inner: StdoutLogger,
|
||||
}
|
||||
|
||||
impl Logger for VerbosityFilter {
|
||||
fn log(&self, verbosity: u8, message: &str) {
|
||||
if verbosity <= self.max_verbosity {
|
||||
self.inner.log(verbosity, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let logger = VerbosityFilter {
|
||||
max_verbosity: 3,
|
||||
inner: StdoutLogger,
|
||||
};
|
||||
logger.log(5, "FYI");
|
||||
logger.log(2, "Uhoh");
|
||||
}
|
1
logger/target/.rustc_info.json
Normal file
1
logger/target/.rustc_info.json
Normal file
@ -0,0 +1 @@
|
||||
{"rustc_fingerprint":6732347950899328623,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.78.0 (9b00956e5 2024-04-29) (Alpine Linux 1.78.0-r0)\nbinary: rustc\ncommit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6\ncommit-date: 2024-04-29\nhost: x86_64-alpine-linux-musl\nrelease: 1.78.0\nLLVM version: 17.0.6\n","stderr":""},"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/usr\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"musl\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"alpine\"\nunix\n","stderr":""}},"successes":{}}
|
3
logger/target/CACHEDIR.TAG
Normal file
3
logger/target/CACHEDIR.TAG
Normal file
@ -0,0 +1,3 @@
|
||||
Signature: 8a477f597d28d172789f06886806bc55
|
||||
# This file is a cache directory tag created by cargo.
|
||||
# For information about cache directory tags see https://bford.info/cachedir/
|
0
logger/target/debug/.cargo-lock
Normal file
0
logger/target/debug/.cargo-lock
Normal file
@ -0,0 +1 @@
|
||||
e93c6c14f8990fed
|
@ -0,0 +1 @@
|
||||
{"rustc":527819051023801553,"features":"[]","declared_features":"","target":16938823611516788830,"profile":11597332650809196192,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/logger-24dda9cfa85dde2e/dep-bin-logger"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
@ -0,0 +1 @@
|
||||
c1fb9f4ae6f812af
|
@ -0,0 +1 @@
|
||||
{"rustc":527819051023801553,"features":"[]","declared_features":"","target":16938823611516788830,"profile":11983525691607113661,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/logger-25d7fa76bb1e13bd/dep-test-bin-logger"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
@ -0,0 +1 @@
|
||||
f8f84ecbc97cbdac
|
@ -0,0 +1 @@
|
||||
{"rustc":527819051023801553,"features":"[]","declared_features":"","target":16938823611516788830,"profile":5601947868832436996,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/logger-93bf7dd47194b21e/dep-bin-logger"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
BIN
logger/target/debug/deps/logger-24dda9cfa85dde2e
Executable file
BIN
logger/target/debug/deps/logger-24dda9cfa85dde2e
Executable file
Binary file not shown.
5
logger/target/debug/deps/logger-24dda9cfa85dde2e.d
Normal file
5
logger/target/debug/deps/logger-24dda9cfa85dde2e.d
Normal file
@ -0,0 +1,5 @@
|
||||
/home/caskd/Sources/Repositories/Personal/Rust/logger/target/debug/deps/logger-24dda9cfa85dde2e: src/main.rs
|
||||
|
||||
/home/caskd/Sources/Repositories/Personal/Rust/logger/target/debug/deps/logger-24dda9cfa85dde2e.d: src/main.rs
|
||||
|
||||
src/main.rs:
|
5
logger/target/debug/deps/logger-25d7fa76bb1e13bd.d
Normal file
5
logger/target/debug/deps/logger-25d7fa76bb1e13bd.d
Normal file
@ -0,0 +1,5 @@
|
||||
/home/caskd/Sources/Repositories/Personal/Rust/logger/target/debug/deps/liblogger-25d7fa76bb1e13bd.rmeta: src/main.rs
|
||||
|
||||
/home/caskd/Sources/Repositories/Personal/Rust/logger/target/debug/deps/logger-25d7fa76bb1e13bd.d: src/main.rs
|
||||
|
||||
src/main.rs:
|
5
logger/target/debug/deps/logger-93bf7dd47194b21e.d
Normal file
5
logger/target/debug/deps/logger-93bf7dd47194b21e.d
Normal file
@ -0,0 +1,5 @@
|
||||
/home/caskd/Sources/Repositories/Personal/Rust/logger/target/debug/deps/liblogger-93bf7dd47194b21e.rmeta: src/main.rs
|
||||
|
||||
/home/caskd/Sources/Repositories/Personal/Rust/logger/target/debug/deps/logger-93bf7dd47194b21e.d: src/main.rs
|
||||
|
||||
src/main.rs:
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
logger/target/debug/logger
Executable file
BIN
logger/target/debug/logger
Executable file
Binary file not shown.
1
logger/target/debug/logger.d
Normal file
1
logger/target/debug/logger.d
Normal file
@ -0,0 +1 @@
|
||||
/home/caskd/Sources/Repositories/Personal/Rust/logger/target/debug/logger: /home/caskd/Sources/Repositories/Personal/Rust/logger/src/main.rs
|
Loading…
Reference in New Issue
Block a user