Fix the debug config feature and --debug flag.

This commit is contained in:
Nick Lewycky
2020-08-03 17:39:16 -07:00
parent dcdebaffdd
commit e942410ef5
4 changed files with 11 additions and 2 deletions

View File

@@ -45,7 +45,9 @@ distance = "0.4"
# For the inspect subcommand # For the inspect subcommand
bytesize = "1.0" bytesize = "1.0"
cfg-if = "0.1" cfg-if = "0.1"
# For debug feature
fern = { version = "0.6", features = ["colored"], optional = true }
log = { version = "0.4", optional = true }
[features] [features]
# Don't add the compiler features in default, please add them on the Makefile # Don't add the compiler features in default, please add them on the Makefile
@@ -94,3 +96,4 @@ llvm = [
"wasmer-compiler-llvm", "wasmer-compiler-llvm",
"compiler", "compiler",
] ]
debug = ["fern", "log"]

View File

@@ -1,4 +1,5 @@
use crate::common::get_cache_dir; use crate::common::get_cache_dir;
use crate::logging;
use crate::store::{CompilerType, EngineType, StoreOptions}; use crate::store::{CompilerType, EngineType, StoreOptions};
use crate::suggestions::suggest_function_exports; use crate::suggestions::suggest_function_exports;
use crate::warning; use crate::warning;
@@ -70,6 +71,10 @@ pub struct Run {
impl Run { impl Run {
/// Execute the run command /// Execute the run command
pub fn execute(&self) -> Result<()> { pub fn execute(&self) -> Result<()> {
#[cfg(feature = "debug")]
if self.debug {
logging::set_up_logging().unwrap();
}
self.inner_execute().with_context(|| { self.inner_execute().with_context(|| {
let compilers = CompilerType::enabled() let compilers = CompilerType::enabled()
.iter() .iter()

View File

@@ -1,3 +1,4 @@
//! Logging functions for the debug feature.
use crate::utils::wasmer_should_print_color; use crate::utils::wasmer_should_print_color;
use fern::colors::{Color, ColoredLevelConfig}; use fern::colors::{Color, ColoredLevelConfig};
use std::time; use std::time;

View File

@@ -16,7 +16,7 @@ byteorder = "1.3"
thiserror = "1" thiserror = "1"
generational-arena = { version = "0.2", features = ["serde"] } generational-arena = { version = "0.2", features = ["serde"] }
libc = { version = "^0.2.69", default-features = false } libc = { version = "^0.2.69", default-features = false }
tracing = "0.1" tracing = { version = "0.1", features = ["log"] }
getrandom = "0.1" getrandom = "0.1"
time = "0.1" time = "0.1"
typetag = "0.1" typetag = "0.1"