logtea 2.0.0

An Ingredient crate for working with LOG files in rettle.
Documentation
  • Coverage
  • 71.43%
    5 out of 7 items documented0 out of 4 items with examples
  • Size
  • Source code size: 35.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.75 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 35s Average build duration of successful builds.
  • all releases: 35s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • slaterb1/logtea
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • slaterb1

logtea

LICENSE License Build Status Crates.io Version Minimum rustc version

This is a generic log file Fill Ingredient crate for use with rettle ETL. This crate uses nom as the parser library to allow any project to define how it wants to parse logs by supplying a custom built parser.

Data Structures

  • FillLogArg: Ingredient params for FillLogTea
  • FillLogTea: Wrapper to simplifiy the creation of the Fill Ingredient to be used in the rettle Pot.

Example

#[derive(Default, Clone, Debug)]
struct LogTea {
    log_type: String,
    datetime: String,
    msg: String,
}

impl Tea for LogTea {
    fn as_any(&self) -> &dyn Any {
        self
    }
}

// Custom parser setup.
fn log_type(input: &str) -> IResult<&str, &str> {
    delimited(char('['), is_not("]"), char(']'))(input)
}

fn datetime(input: &str) -> IResult<&str, &str> {
    take(19u8)(input)
}

fn msg(input: &str) -> IResult<&str, &str> {
    not_line_ending(input)
}

fn parse_log(input: &str) -> IResult<&str, LogTea> {
    // Parse log attributes.
    let (input, log_type) = log_type(input)?;
    let (input, _) = tag(" - ")(input)?;
    let (input, datetime) = datetime(input)?;
    let (input, _) = space1(input)?;
    let (input, msg) = msg(input)?;

    // Convert &str to String
    let log_type = String::from(log_type);
    let datetime = String::from(datetime);
    let msg = String::from(msg);
    Ok((input, LogTea { log_type, datetime, msg }))
}

fn main() {
    let test_fill_logarg = FillLogArg::new("fixtures/log.LOG", 50, parse_log);

    let brewery = Brewery::new(4, Instant::now());
    let fill_logtea = FillLogTea::new::<LogTea>("log_tea_source", "log_fixture", test_fill_logarg);

    let new_pot = Pot::new()
        .add_source(fill_logtea);

    // Steep/Pour operations of choice

    new_pot.brew(&brewery);
}