| Crates.io | substreams-sink-winston |
| lib.rs | substreams-sink-winston |
| version | 0.1.2 |
| created_at | 2023-02-18 22:26:10.879675+00 |
| updated_at | 2023-02-20 19:38:44.674377+00 |
| description | Substreams Winston Logger sink module |
| homepage | https://github.com/pinax-network/substreams-sink-winston |
| repository | https://github.com/pinax-network/substreams-sink-winston |
| max_upload_size | |
| id | 788504 |
| size | 45,882 |
Substreams Winston Logger sink module
substreams-sink-winstonis 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.
$ cargo add substreams-sink-winston
Cargo.toml
[dependencies]
substreams = "0.5"
substreams-sink-winston = "0.1"
src/lib.rs
use substreams::errors::Error;
use substreams_sink_winston::{Logger, LoggerOperations};
#[substreams::handlers::map]
fn prom_out(
... some stores ...
) -> Result<LoggerOperations, Error> {
// Initialize Winston Logger operations container
let mut log_ops: 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"));
// Include Metadata
let meta = Meta::from(vec!(["key", "value"]));
log_ops.push(logger.info("message").with(meta));
Ok(log_ops)
}