Giter VIP home page Giter VIP logo

logsnag-rust's Introduction

A Logsnag API Wrapper for Rust

Crate API

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.

Note: this crate is currently being actively developed. It may change a lot until v1.0. Keep this in mind if you're using it for production apps.

Features

  • Publish logs to channels with specified event, optional description, icon, and notify flag
  • Publish insights with a specified title, event, value, and an optional icon
  • Support tags
  • Support validation for inputs on the strings (some)

Getting Started

First, add logsnag to your Cargo.toml:

[dependencies]
logsnag = "0.6.2"

Then, import it in your file(s).

use logsnag::Logsnag;

Usage

Here is a basic example of how to use the Logsnag client. It uses a builder to add on to the initial event/insight for the optional parameters. Anything that has with_ is an optional function. Note that for tags, you must add one at a time with with_tag():

use logsnag::Logsnag;

async fn main() {

    let logsnag = Logsnag::new(
        env::var("LOGSNAG_API_KEY").expect("No Logsnag API Key (LOGSNAG_API_KEY) found in Environment.")
        env::var("LOGSNAG_PROJECT").expect("No Logsnag Project (LOGSNAG_PROJECT) found in Environment.")
    );

    let publish_result = logsnag.event("channel","event")
        .with_notify(true)
        .with_description("description")
        .with_icon("❤️")
        .with_tag("tag", "value")
        .with_tag("tag2", "value2")
        .publish()
        .await;

    let insight_result = logsnag.insight("title", "value") //value can be also an Int or a bool
        .with_icon("🟢")
        .publish()
        .await;
}

Auto Validation

Tags have a specific format that they need to be in to pass correctly to publish an event. They need to be lowercase, have no special characters, no spaces, and no uppercase characters. Only dashes are allowed.

with_tag() automatically will parse your text and strip the unwanted characters out to prevent runtime errors. There's not a currently known way to check validation on compile time within Rust, but if that changes we will implement it. If you know of a way to do this within functions let us know.

Docs

See the API Documentation for more details around the methods we use in this library.

Contributing

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.

logsnag-rust's People

Contributors

rhh4x0r avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.