3 releases
0.1.2 | Oct 28, 2022 |
---|---|
0.1.1 | Oct 27, 2022 |
0.1.0 | Oct 27, 2022 |
#739 in Debugging
25KB
517 lines
Rokkett Logger
Lib containing the client and server for a centralized logging setup.
Client implementation
To use rokkett-logger, add it as a dependency to your Cargo.toml
.
$ cargo add rokkett-logger
To configure the logger, create a new RokkettLogger
which shall be initialized only once before any logs are generated.
#[tokio::main]
async fn main() {
// register logger
RokkettLogger::new("127.0.0.1:5500", "My App", Some("secret"))
.expect("failed to create logger");
// start logging :)
log::info!("Hello, world!");
}
See examples for more examples.
Server implementation
To use rokkett-logger, add it as a dependency to your Cargo.toml
.
$ cargo add rokkett-logger
#[tokio::main]
async fn main() {
let on_login = |token, _addr| token == "secret".to_string();
let on_log = |message, _addr| {
println!("{message}");
Status::Ok
};
Server::new(on_login, on_log).listen("127.0.0.1", 5500).await;
}
See examples for more examples.
License
Rokkett-Logger is distributed under the terms of the Apache-2.0 license.
Find an easy explanation on choosealicense.com/licenses/apache-2.0.
Dependencies
~4–12MB
~137K SLoC