Skip to content

Commit 89e1008

Browse files
authored
Try #1147:
2 parents a8ed5b9 + 397343e commit 89e1008

File tree

25 files changed

+167
-76
lines changed

25 files changed

+167
-76
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## **[Unreleased]**
44

5+
- [#1147](https://github.com/wasmerio/wasmer/pull/1147) Remove `log` and `trace` macros from `wasmer-runtime-core`, remove `debug` and `trace` features from `wasmer-*` crates, use the `log` crate for logging and use `fern` in the Wasmer CLI binary to output log messages. To disable colorized output, set the `WASMER_DISABLE_COLOR` environment variable.
56
- [#1128](https://github.com/wasmerio/wasmer/pull/1128) Fix a crash when a host function is missing and the `allow_missing_functions` flag is enabled
67
- [#1099](https://github.com/wasmerio/wasmer/pull/1099) Remove `backend::Backend` from `wasmer_runtime_core`
78
- [#1097](https://github.com/wasmerio/wasmer/pull/1097) Move inline breakpoint outside of runtime backend

Cargo.lock

+66-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ include = [
2222
[dependencies]
2323
byteorder = "1.3"
2424
errno = "0.2"
25+
fern = { version = "0.5", features = ["colored"], optional = true }
26+
# statically turn off logging for wasmer by default, fetaures override this
27+
log = "0.4"
2528
structopt = "0.3"
2629
wabt = "0.9.1"
2730
wasmer-clif-backend = { path = "lib/clif-backend", optional = true }
@@ -78,10 +81,9 @@ typetag = "0.1" # used by the plugin example
7881
[features]
7982
default = ["fast-tests", "wasi", "backend-cranelift"]
8083
"loader-kernel" = ["wasmer-kernel-loader"]
81-
debug = ["wasmer-runtime-core/debug"]
82-
trace = ["wasmer-runtime-core/trace"]
84+
debug = ["fern", "log/max_level_debug", "log/release_max_level_debug"]
85+
trace = ["fern", "log/max_level_trace", "log/release_max_level_trace"]
8386
docs = ["wasmer-runtime/docs"]
84-
extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
8587
# This feature will allow cargo test to run much faster
8688
fast-tests = []
8789
backend-cranelift = [

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ check: check-bench
258258

259259
# Release
260260
release:
261-
cargo build --release --features backend-singlepass,backend-cranelift,backend-llvm,loader-kernel,experimental-io-devices
261+
cargo build --release --features backend-singlepass,backend-cranelift,backend-llvm,loader-kernel,experimental-io-devices,log/release_max_level_off
262262

263263
# Only one backend (cranelift)
264264
release-clif:

lib/clif-backend/Cargo.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,4 @@ version = "0.0.7"
3737

3838
[target.'cfg(windows)'.dependencies]
3939
winapi = { version = "0.3", features = ["errhandlingapi", "minwindef", "minwinbase", "winnt"] }
40-
wasmer-win-exception-handler = { path = "../win-exception-handler", version = "0.12.0" }
41-
42-
[features]
43-
debug = ["wasmer-runtime-core/debug"]
40+
wasmer-win-exception-handler = { path = "../win-exception-handler", version = "0.12.0" }

lib/emscripten/Cargo.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ edition = "2018"
1313
byteorder = "1.3"
1414
lazy_static = "1.4"
1515
libc = "0.2.60"
16+
log = "0.4"
1617
time = "0.1"
1718
wasmer-runtime-core = { path = "../runtime-core", version = "0.12.0" }
1819

1920
[target.'cfg(windows)'.dependencies]
2021
getrandom = "0.1"
21-
22-
[features]
23-
debug = ["wasmer-runtime-core/debug"]

lib/emscripten/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#[macro_use]
1414
extern crate wasmer_runtime_core;
15+
#[macro_use]
16+
extern crate log;
1517

1618
use lazy_static::lazy_static;
1719
use std::cell::UnsafeCell;

lib/llvm-backend/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,4 @@ rustc_version = "0.2"
4646
wabt = "0.9.1"
4747

4848
[features]
49-
debug = ["wasmer-runtime-core/debug"]
5049
test = []

lib/runtime-c-api/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ optional = true
3939

4040
[features]
4141
default = ["cranelift-backend", "wasi"]
42-
debug = ["wasmer-runtime/debug"]
4342
singlepass-backend = ["wasmer-runtime/singlepass", "wasmer-runtime/default-backend-singlepass"]
4443
cranelift-backend = ["wasmer-runtime/cranelift", "wasmer-runtime/default-backend-cranelift"]
4544
llvm-backend = ["wasmer-runtime/llvm", "wasmer-runtime/default-backend-llvm"]

lib/runtime-core/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,5 @@ rustc_version = "0.2"
5050
cc = "1.0"
5151

5252
[features]
53-
debug = []
54-
trace = ["debug"]
5553
managed = []
5654
deterministic-execution = ["wasmparser/deterministic"]

lib/runtime-core/src/macros.rs

-46
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,3 @@
1-
/// Prints a log message with args, similar to println, when the debug feature is enabled.
2-
/// If the debug feature is disabled, arguments are not evaluated or printed.
3-
#[macro_export]
4-
#[cfg(feature = "debug")]
5-
macro_rules! debug {
6-
($fmt:expr) => (println!(concat!("[{}] wasmer-runtime(:{}) ", $fmt), {
7-
let time = ::std::time::SystemTime::now().duration_since(::std::time::UNIX_EPOCH).expect("Can't get time");
8-
format!("{}.{:03}", time.as_secs(), time.subsec_millis())
9-
}, line!()));
10-
($fmt:expr, $($arg:tt)*) => (println!(concat!("[{}] wasmer-runtime(:{}) ", $fmt, "\n"), {
11-
let time = ::std::time::SystemTime::now().duration_since(::std::time::UNIX_EPOCH).expect("Can't get time");
12-
format!("{}.{:03}", time.as_secs(), time.subsec_millis())
13-
}, line!(), $($arg)*));
14-
}
15-
16-
/// Prints a log message with args, similar to println, when the debug feature is enabled.
17-
/// If the debug feature is disabled, arguments are not evaluated or printed.
18-
#[macro_export]
19-
#[cfg(not(feature = "debug"))]
20-
macro_rules! debug {
21-
($fmt:expr) => {};
22-
($fmt:expr, $($arg:tt)*) => {};
23-
}
24-
25-
/// Prints a log message with args, similar to println, when the trace feature is enabled.
26-
/// If the trace feature is disabled, arguments are not evaluated or printed.
27-
#[macro_export]
28-
#[cfg(feature = "trace")]
29-
macro_rules! trace {
30-
($fmt:expr) => {
31-
debug!($fmt)
32-
};
33-
($fmt:expr, $($arg:tt)*) => {
34-
debug!($fmt, $($arg)*);
35-
}
36-
}
37-
38-
/// Prints a log message with args, similar to println, when the trace feature is enabled.
39-
/// If the trace feature is disabled, arguments are not evaluated or printed.
40-
#[macro_export]
41-
#[cfg(not(feature = "trace"))]
42-
macro_rules! trace {
43-
($fmt:expr) => {};
44-
($fmt:expr, $($arg:tt)*) => {};
45-
}
46-
471
/// Helper macro to create a new `Func` object using the provided function pointer.
482
///
493
/// # Usage

lib/runtime/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ default = ["cranelift", "default-backend-cranelift"]
4646
docs = []
4747
cranelift = ["wasmer-clif-backend"]
4848
cache = ["cranelift"]
49-
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
5049
llvm = ["wasmer-llvm-backend"]
5150
singlepass = ["wasmer-singlepass-backend"]
5251
default-backend-singlepass = ["singlepass"]

lib/wasi-experimental-io-devices/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ license = "MIT"
1212
maintenance = { status = "experimental" }
1313

1414
[dependencies]
15+
log = "0.4"
1516
minifb = "0.13"
1617
wasmer-wasi = { version = "0.12.0", path = "../wasi" }
1718
wasmer-runtime-core = { version = "0.12.0", path = "../runtime-core" }

lib/wasi-experimental-io-devices/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#[macro_use]
2+
extern crate log;
3+
14
use serde::{Deserialize, Serialize};
25
use std::collections::{BTreeSet, VecDeque};
36
use std::convert::TryInto;
47
use std::io::{Read, Seek, SeekFrom, Write};
5-
use wasmer_runtime_core::debug;
68
use wasmer_wasi::{
79
state::{Fd, WasiFile, WasiFs, WasiFsError, ALL_RIGHTS, VIRTUAL_ROOT_FD},
810
types::*,

lib/wasi/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
2323
#[cfg(target = "windows")]
2424
extern crate winapi;
25+
#[macro_use]
26+
extern crate log;
2527

2628
#[macro_use]
2729
mod macros;

lib/wasi/src/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ macro_rules! wasi_try {
33
let res: Result<_, crate::syscalls::types::__wasi_errno_t> = $expr;
44
match res {
55
Ok(val) => {
6-
wasmer_runtime_core::trace!("wasi::wasi_try::val: {:?}", val);
6+
trace!("wasi::wasi_try::val: {:?}", val);
77
val
88
}
99
Err(err) => {
10-
wasmer_runtime_core::trace!("wasi::wasi_try::err: {:?}", err);
10+
trace!("wasi::wasi_try::err: {:?}", err);
1111
return err;
1212
}
1313
}

lib/wasi/src/state/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use std::{
3131
path::{Path, PathBuf},
3232
time::SystemTime,
3333
};
34-
use wasmer_runtime_core::{debug, vm::Ctx};
34+
use wasmer_runtime_core::vm::Ctx;
3535

3636
/// the fd value of the virtual root
3737
pub const VIRTUAL_ROOT_FD: __wasi_fd_t = 3;

lib/wasi/src/state/types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use std::{
99
path::PathBuf,
1010
time::SystemTime,
1111
};
12-
use wasmer_runtime_core::debug;
1312

1413
/// Error type for external users
1514
#[derive(Copy, Clone, Debug, PartialEq, Eq)]

lib/wasi/src/syscalls/legacy/snapshot0.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::ptr::{Array, WasmPtr};
22
use crate::syscalls;
33
use crate::syscalls::types::{self, snapshot0};
4-
use wasmer_runtime_core::{debug, vm::Ctx};
4+
use wasmer_runtime_core::vm::Ctx;
55

66
/// Wrapper around `syscalls::fd_filestat_get` with extra logic to handle the size
77
/// difference of `wasi_filestat_t`

lib/wasi/src/syscalls/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::borrow::Borrow;
2121
use std::cell::Cell;
2222
use std::convert::{Infallible, TryInto};
2323
use std::io::{self, Read, Seek, Write};
24-
use wasmer_runtime_core::{debug, memory::Memory, vm::Ctx};
24+
use wasmer_runtime_core::{memory::Memory, vm::Ctx};
2525

2626
#[cfg(any(target_os = "linux", target_os = "macos"))]
2727
pub use unix::*;

lib/wasi/src/syscalls/windows.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::syscalls::types::*;
22
use std::cell::Cell;
3-
use wasmer_runtime_core::debug;
43

54
pub fn platform_clock_res_get(
65
clock_id: __wasi_clockid_t,

0 commit comments

Comments
 (0)