Giter Site home page Giter Site logo

cosmo0920 / fruently Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 6.0 1.18 MB

A yet another Fluentd logger for Rust. a.k.a. verification of Fluentd's forward protocol playground.

License: MIT License

Rust 80.01% TeX 19.65% Ruby 0.34%
rust fluentd-logger fluentd

fruently's Introduction

Fruently

Build Status Build status

Documentation

A yet another Fluentd logger for Rust. Any version newer than Rust 1.18.0 is supported.

Note

If you use this library in Windows, please install Visual Studio 2015 or 2017 and rust compiler which is targeted for MSVC API and its package manager, which is called cargo via rustup.rs.

And then, follow the below usage instructions.

Usage

Add this to your Cargo.toml:

[dependencies]
fruently = "~0.10.0"

and this to your crate root:

extern crate fruently;

Complete examples

Forwarding with JSON

extern crate fruently;
use fruently::fluent::Fluent;
use std::collections::HashMap;
use fruently::forwardable::JsonForwardable;

fn main() {
    let mut obj: HashMap<String, String> = HashMap::new();
    obj.insert("name".to_string(), "fruently".to_string());
    let fruently = Fluent::new("127.0.0.1:24224", "test");
    match fruently.post(&obj) {
        Err(e) => println!("{:?}", e),
        Ok(_) => return,
    }
}

Forwarding with msgpack

extern crate fruently;
use fruently::fluent::Fluent;
use std::collections::HashMap;
use fruently::forwardable::MsgpackForwardable;

fn main() {
    let mut obj: HashMap<String, String> = HashMap::new();
    obj.insert("name".to_string(), "fruently".to_string());
    let fruently = Fluent::new("127.0.0.1:24224", "test");
    match fruently.post(&obj) {
        Err(e) => println!("{:?}", e),
        Ok(_) => return,
    }
}

Forwarding asynchronously

Fruently does not have asynchronous API because Rust has std::thread::spawn function to make asynchronous API from synchronous one.

If you want to send records into Fluentd asynchronously, please consider using std::thread::spawn like: asynchronous example.

Backward compatibility

Using with Fluentd v0.12, you must specify time-as-integer feature flag:

[build-dependencies.fruently]
version = "~0.10.0"
features = ["time-as-integer"]

Related Articles

LICENSE

MIT.

fruently's People

Contributors

cosmo0920 avatar guangie88 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fruently's Issues

update byteoder

The latest byteorder is v1.1.0.

Could you update Cargo.toml unless compatibility issues?
(or use ^1.0.0 instead of ~1.0 as the version specification)

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.