bflog 0.3.1

Very tiny logging framework made for microservices.
Documentation
use std::str::FromStr;

mod logger;
mod output;
mod sink;

pub use self::logger::{ContextWriter, Logger};
pub use self::sink::LogSink;
pub use bytes::Bytes;
pub use log::{debug, error, info, trace, warn, Level, LevelFilter};

/// One of the possible log formats.
#[derive(Clone, Copy)]
pub enum Format {
  /// Outputs each log entry as a JSON object separated by a newline.
  Json,
  /// Outputs each log entry separated by a newline.
  Plain,
  /// Outputs each log entry separated by a newline, in color.
  Color,
  /// Outputs each log entry separated by a newline, in color with icons.
  Modern,
}

// Implements `FromStr` to parse lowercase `Format` names.
impl FromStr for Format {
  type Err = ();

  fn from_str(s: &str) -> Result<Format, Self::Err> {
    match s.as_ref() {
      "json" => Ok(Format::Json),
      "plain" => Ok(Format::Plain),
      "color" => Ok(Format::Color),
      "modern" => Ok(Format::Modern),
      _ => Err(()),
    }
  }
}