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.
- Substreams GoogleSheet sink module
- Substreams CSV sink module
- Substreams Telegram sink module
- Substreams Discord sink module
- service
- defaultMeta
- Emergency: system is unusable
- Alert: action must be taken immediately
- Critical: critical conditions
- Error: error conditions
- Warning: warning conditions
- Notice: normal but significant condition
- Informational: informational messages
- Debug: debug-level messages
-
ignorePrivate -
private
$ 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)
}