3 releases

0.1.2 Feb 20, 2023
0.1.1 Feb 19, 2023
0.1.0 Feb 18, 2023

#4 in #pinax

MIT/Apache

31KB
408 lines

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

  • Substreams GoogleSheet sink module
  • Substreams CSV sink module
  • Substreams Telegram sink module
  • Substreams Discord sink module

🛠 Feature Roadmap

Create Logger

  • service
  • defaultMeta

Logging

  • 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

Filtering info Objects

  • ignorePrivate
  • private

Install

$ cargo add substreams-sink-winston

Quickstart

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)
}

Dependencies

~2.5MB
~51K SLoC