Substreams Winston Logger sink module

github crates.io docs.rs GitHub Workflow Status

substreams-sink-winston is a tool that allows developers to pipe data extracted metrics from a blockchain into a standard Winston Logging message conforming to the severity ordering specified by RFC5424.

📖 Documentation

https://docs.rs/substreams-sink-winston

Further resources

Related Sinks

🛠 Feature Roadmap

Create Logger

Logging

Filtering info Objects

Install

bash $ cargo add substreams-sink-winston

Quickstart

Cargo.toml

toml [dependencies] substreams = "0.5" substreams-sink-winston = "0.1"

src/lib.rs

```rust use std::collections::HashMap; use substreams::errors::Error; use substreamssinkwinston::{Logger, LoggerOperations};

[substreams::handlers::map]

fn promout( ... some stores ... ) -> Result { // Initialize Winston Logger operations container let mut logops: LoggerOperations = Default::default();

// Create Logger
// ==============
let mut logger = Logger::from("user-service");

// Informational: informational messages
log_ops.push(logger.info("info message"));

// Error: error conditions
log_ops.push(logger.error("error message"));

// Create a HashMap of metadata
let meta = HashMap::from([("label1".to_string(), "value1".to_string())]);
log_ops.push(logger.info("message").with(meta));

Ok(log_ops)

} ```