Substreams
Winston Logger
sink module
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.
bash
$ cargo add substreams-sink-winston
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};
fn promout(
... some stores ...
) -> Result
// 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.with(meta).info("message"));
Ok(log_ops)
} ```