Avoid verbose logging in test harness

next
Sayan Nandan 3 years ago
parent cc6a1b7f27
commit f9b997c1f1
No known key found for this signature in database
GPG Key ID: 8BC07A0A4D41DD52

3
Cargo.lock generated

@ -668,9 +668,6 @@ checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
[[package]]
name = "libsky"
version = "0.7.4"
dependencies = [
"termcolor",
]
[[package]]
name = "libstress"

@ -48,6 +48,8 @@ fn main() {
Builder::new()
.parse_filters(&env::var("SKYHARNESS_LOG").unwrap_or_else(|_| "info".to_owned()))
.init();
// avoid verbose logging
env::set_var("SKY_LOG", "error");
if let Err(e) = runner() {
error!("harness failed with: {}", e);
process::exit(0x01);

@ -7,5 +7,3 @@ version = "0.7.4"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
# external deps
termcolor = "1.1.3"

@ -31,7 +31,6 @@
//!
//! This contains modules which are shared by both the `cli` and the `server` modules
pub mod util;
use std::error::Error;
/// A generic result
pub type TResult<T> = Result<T, Box<dyn Error>>;

@ -1,58 +0,0 @@
/*
* Created on Tue Aug 18 2020
*
* This file is a part of Skytable
* Skytable (formerly known as TerrabaseDB or Skybase) is a free and open-source
* NoSQL database written by Sayan Nandan ("the Author") with the
* vision to provide flexibility in data modelling without compromising
* on performance, queryability or scalability.
*
* Copyright (c) 2020, Sayan Nandan <ohsayan@outlook.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
pub mod terminal {
//! Utilities for Terminal I/O
use std::fmt;
use std::io::Write;
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
/// Write to stdout with
pub fn write_with_col<T: fmt::Display>(item: T, color: Option<Color>) -> fmt::Result {
let mut stdout = StandardStream::stdout(ColorChoice::Always);
if stdout.set_color(ColorSpec::new().set_fg(color)).is_err() {
return Err(fmt::Error);
}
if writeln!(&mut stdout, "{}", item).is_err() {
return Err(fmt::Error);
}
if stdout.reset().is_err() {
return Err(fmt::Error);
}
Ok(())
}
pub fn write_info<T: fmt::Display>(item: T) -> fmt::Result {
write_with_col(item, Some(Color::Cyan))
}
pub fn write_warning<T: fmt::Display>(item: T) -> fmt::Result {
write_with_col(item, Some(Color::Yellow))
}
pub fn write_error<T: fmt::Display>(item: T) -> fmt::Result {
write_with_col(item, Some(Color::Red))
}
pub fn write_success<T: fmt::Display>(item: T) -> fmt::Result {
write_with_col(item, Some(Color::Green))
}
}

@ -34,7 +34,6 @@ use crate::diskstore::flock::FileLock;
use crate::services;
use crate::storage::v1::sengine::SnapshotEngine;
use crate::util::os::TerminationSignal;
use libsky::util::terminal;
use std::sync::Arc;
use std::thread::sleep;
use tokio::{
@ -193,7 +192,7 @@ pub fn finalize_shutdown(corestore: Corestore, pid_file: FileLock) {
});
okay &= services::pre_shutdown_cleanup(pid_file, Some(corestore.get_store()));
if okay {
terminal::write_success("Goodbye :)").unwrap()
log::info!("Goodbye :)");
} else {
log::error!("Didn't terminate successfully");
crate::exit_error();

@ -129,9 +129,9 @@ fn check_args_and_get_cfg() -> (ConfigurationSet, Option<String>) {
match config::get_config() {
Ok(cfg) => {
if cfg.is_artful() {
println!("Skytable v{} | {}\n{}", VERSION, URL, TEXT);
log::info!("Skytable v{} | {}\n{}", VERSION, URL, TEXT);
} else {
println!("Skytable v{} | {}", VERSION, URL);
log::info!("Skytable v{} | {}", VERSION, URL);
}
if cfg.is_custom() {
log::info!("Using settings from supplied configuration");

Loading…
Cancel
Save