Relastic

Simple rust lib inspired by Serilog for application-wide logging:

Purpose

Log to Elastic from Rust applications

Intended consumers

Everyone. Do not use in production without first assessing the risks involved first.

Main technologies

Rust NixShell

Available at

crates.io (relastic)

Requirements

More documentation

Testing locally

Known issues

Usage

```rs fn main() { let elasticconfig = match elasticconfig::ElasticConfig::new() { Ok(x) => x, Err(err) => panic!("Elastic not/improperly configured: {:?}", err), }; log::setupelasticlog( elastic_config, 100, );

/* ... */

log::flush();

} ```

Usage with Rocket.rs

Rocket does not allow blocking services to run in it's Tokio runtime. We were unable to discover an easy for solution to create a globally available logging function, without being fully dependent on Rocket dependencies. To use it with Rocket thefore requires you to define your own Tokio runtime instead of relying on Rocket setup magic.

Here's how you may do it:

rs fn main() { let elastic_config = match elastic_config::ElasticConfig::new() { Ok(x) => x, Err(err) => panic!("Elastic not/improperly configured: {:?}", err), }; log::setup_elastic_log( elastic_config, 100, ); // Create multi-threaded tokio runtime for rocket let rt = tokio::runtime::Runtime::new().unwrap(); rt.block_on(async { rocket_main().await; }); log::flush(); }

Contributing

You are welcome to reports bugs, contribute code or open issues.