Browse Source

feature-gate ANSI frontend

to reduce minimal needed dependdencies
main
ThePerkinrex 4 years ago
parent
commit
80f9590ca2
No known key found for this signature in database GPG Key ID: FD81DE6D75E20917
  1. 9
      server/Cargo.toml
  2. 9
      server/src/logger.rs

9
server/Cargo.toml

@ -6,6 +6,10 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["ansi"]
ansi = ["crossterm"]
[dependencies]
# Utilities
rand = "0.8"
@ -33,11 +37,10 @@ prost = "0.8"
prost-types = "0.8"
# Database (SQLite)
rusqlite = {version = "0.25", features=["bundled"]}
# sqlx = { version = "0.3", default-features = false, features = [ "runtime-tokio", "macros", "sqlite" ] }
rusqlite = {version = "0.26", features=["bundled"]}
# TUI
crossterm = "0.20"
crossterm = {version = "0.21", optional = true}
log = "0.4"
fern = {version = "0.6", features = ["colored"]}
chrono = "0.4"

9
server/src/logger.rs

@ -1,7 +1,12 @@
use std::sync::mpsc;
#[cfg(feature = "ansi")]
mod ansi;
#[cfg(feature = "ansi")]
use ansi::ANSIFrontend;
mod barebones;
use barebones::BarebonesFrontend;
use fern::Dispatch;
@ -11,7 +16,6 @@ use crate::{
server_properties::ServerProperties,
};
use self::{ansi::ANSIFrontend, barebones::BarebonesFrontend};
pub type Stdout = mpsc::Sender<String>;
pub type Stdin<T> = mpsc::Receiver<T>;
@ -63,9 +67,10 @@ pub fn setup(properties: &ServerProperties) -> anyhow::Result<(Close, Stdin<Stri
// TODO select logging frontend
match properties.logger.as_str() {
"barebones" => BarebonesFrontend::setup(properties, d),
#[cfg(feature = "ansi")]
"ANSI" => ANSIFrontend::setup(properties, d),
x => {
println!("Unrecognized logging frontend {}, please select a valid one (barebones, ANSI) from the ones featured on your build, whose list could be smaller than the one shown", x);
println!("Unrecognized logging frontend {}, please select a valid one (barebones, ANSI) from the ones featured on your build, that could have less options than the ones shown", x);
Err(anyhow::anyhow!("Unrecognized logging frontend"))
}
}

Loading…
Cancel
Save