18 releases (9 breaking)

Uses old Rust 2015

0.10.0 Feb 25, 2018
0.9.1 Oct 11, 2017
0.9.0 May 12, 2017
0.8.0 Feb 25, 2017
0.2.0 Mar 29, 2016
Download history 96/week @ 2021-02-23 20/week @ 2021-03-02 16/week @ 2021-03-09 12/week @ 2021-03-16 95/week @ 2021-03-23 49/week @ 2021-03-30 37/week @ 2021-04-06 64/week @ 2021-04-13 58/week @ 2021-04-20 34/week @ 2021-04-27 84/week @ 2021-05-04 36/week @ 2021-05-11 29/week @ 2021-05-18 16/week @ 2021-05-25 48/week @ 2021-06-01 47/week @ 2021-06-08

231 downloads per month

Custom license

185KB
892 lines

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.

Dependencies

~2.3–3.5MB
~71K SLoC