logsnag
is a simple and efficient Rust library for interacting with the Logsnag API. It supports asynchronous requests and allows easy publication of logs and insights.
First, add logsnag
to your Cargo.toml
:
toml
[dependencies]
logsnag = "0.3.0"
Then, import it in your file(s).
rust
use logsnag::Logsnag;
use logsnag::models::InsightValue; //Only required for Insights
Here is a basic example of how to use the Logsnag
client:
```rust use logsnag::Logsnag; use logsnag::models::InsightValue;
async fn main() { let logsnag = Logsnag::new( env::var("LOGSNAGAPIKEY").expect("No Logsnag API Key found"), env::var("LOGSNAG_PROJECT").expect("No Logsnag Project found") );
//Use the following for Raw Strings
//let client = Logsnag::new("my-api-token".to_string(), "my-project".to_string());
let publish_response = logsnag.publish(
"channel".to_string(),
"event".to_string(),
Some("description".to_string()),
Some("❤️".to_string()),
Some(true)
).await.expect("Failed to publish log");
let insight_response = logsnag.insight(
"title".to_string(),
"event".to_string(),
InsightValue::Str("online"), //InsightValue::Int(69), InsightValue::Bool(false)
Some("❤️".to_string())
).await.expect("Failed to publish insight");
} ```
See the API Documentation for more details.
Please feel free to submit issues, fork the repository and send pull requests!
Any questions, you can find me (rhh4x0r) on the Official Logsnag Discord Server or submit an issue.