clif-util: always use pretty-env-logger (#4443)

Rather than sometimes using `file-per-thread-logger`.

Also remove the debug CLI flags, so that we can always just define
`RUST_LOG=...` to get logging and don't need to also do other things.
This commit is contained in:
Nick Fitzgerald
2022-07-13 13:43:12 -07:00
committed by GitHub
parent 4ea46c3ca8
commit f7767eb352
9 changed files with 2 additions and 54 deletions

View File

@@ -15,14 +15,9 @@ pub struct Options {
/// Specify input file(s) to be used. Use '-' for stdin.
#[clap(required = true)]
files: Vec<PathBuf>,
/// Enable debug output on stderr/stdout
#[clap(short)]
debug: bool,
}
pub fn run(options: &Options) -> Result<()> {
crate::handle_debug_flag(options.debug);
for (i, f) in options.files.iter().enumerate() {
if i != 0 {
println!();

View File

@@ -13,7 +13,6 @@
)]
use clap::Parser;
use cranelift_codegen::dbg::LOG_FILENAME_PREFIX;
use std::path::PathBuf;
mod bugpoint;
@@ -31,14 +30,6 @@ mod souper_harvest;
#[cfg(feature = "wasm")]
mod wasm;
fn handle_debug_flag(debug: bool) {
if debug {
pretty_env_logger::init();
} else {
file_per_thread_logger::initialize(LOG_FILENAME_PREFIX);
}
}
/// Cranelift code generator utility.
#[derive(Parser)]
enum Commands {
@@ -73,10 +64,6 @@ struct TestOptions {
#[clap(short = 'T')]
time_passes: bool,
/// Enable debug output on stderr/stdout
#[clap(short = 'd')]
debug: bool,
/// Specify an input file to be used. Use '-' for stdin.
#[clap(required = true)]
files: Vec<PathBuf>,
@@ -93,10 +80,6 @@ struct PassOptions {
#[clap(short = 'T')]
time_passes: bool,
/// Enable debug output on stderr/stdout
#[clap(short)]
debug: bool,
/// Specify an input file to be used. Use '-' for stdin.
file: PathBuf,
@@ -113,6 +96,8 @@ struct PassOptions {
struct CompiledWithoutSupportOptions {}
fn main() -> anyhow::Result<()> {
pretty_env_logger::init();
match Commands::parse() {
Commands::Cat(c) => cat::run(&c)?,
Commands::Run(r) => run::run(&r)?,
@@ -135,7 +120,6 @@ fn main() -> anyhow::Result<()> {
),
Commands::Test(t) => {
handle_debug_flag(t.debug);
cranelift_filetests::run(
t.verbose,
t.time_passes,
@@ -146,7 +130,6 @@ fn main() -> anyhow::Result<()> {
)?;
}
Commands::Pass(p) => {
handle_debug_flag(p.debug);
cranelift_filetests::run_passes(
p.verbose,
p.time_passes,

View File

@@ -37,14 +37,9 @@ pub struct Options {
/// Specify an input file to be used. Use '-' for stdin.
files: Vec<PathBuf>,
/// Enable debug output on stderr/stdout
#[clap(short)]
debug: bool,
}
pub fn run(options: &Options) -> Result<()> {
crate::handle_debug_flag(options.debug);
let parsed = parse_sets_and_triple(&options.settings, &options.target)?;
for path in &options.files {
let name = String::from(path.as_os_str().to_string_lossy());

View File

@@ -17,10 +17,6 @@ pub struct Options {
#[clap(required = true)]
files: Vec<PathBuf>,
/// Enable debug output on stderr/stdout
#[clap(short)]
debug: bool,
/// Be more verbose
#[clap(short, long)]
verbose: bool,
@@ -28,8 +24,6 @@ pub struct Options {
/// Run files through the Cranelift interpreter, interpreting any functions with annotations.
pub fn run(options: &Options) -> anyhow::Result<()> {
crate::handle_debug_flag(options.debug);
let mut total = 0;
let mut errors = 0;
for file in iterate_files(&options.files) {
@@ -179,7 +173,6 @@ mod test {
fn filetests() {
run(&Options {
files: vec![PathBuf::from("../filetests/filetests/interpreter")],
debug: true,
verbose: true,
})
.unwrap()

View File

@@ -16,14 +16,9 @@ pub struct Options {
/// Specify an input file to be used. Use '-' for stdin.
#[clap(required = true)]
files: Vec<PathBuf>,
/// Enable debug output on stderr/stdout
#[clap(short)]
debug: bool,
}
pub fn run(options: &Options) -> Result<()> {
crate::handle_debug_flag(options.debug);
for (i, f) in options.files.iter().enumerate() {
if i != 0 {
println!();

View File

@@ -17,17 +17,12 @@ pub struct Options {
#[clap(required = true)]
files: Vec<PathBuf>,
/// Enable debug output on stderr/stdout
#[clap(short)]
debug: bool,
/// Be more verbose
#[clap(short, long)]
verbose: bool,
}
pub fn run(options: &Options) -> Result<()> {
crate::handle_debug_flag(options.debug);
let stdin_exist = options
.files
.iter()

View File

@@ -90,10 +90,6 @@ pub struct Options {
/// Specify an input file to be used. Use '-' for stdin.
files: Vec<PathBuf>,
/// Enable debug output on stderr/stdout
#[clap(short)]
debug: bool,
/// Print bytecode size
#[clap(short = 'X')]
print_size: bool,
@@ -137,8 +133,6 @@ impl std::str::FromStr for ColorOpt {
}
pub fn run(options: &Options) -> Result<()> {
crate::handle_debug_flag(options.debug);
let parsed = parse_sets_and_triple(&options.settings, &options.target)?;
for path in &options.files {
let name = String::from(path.as_os_str().to_string_lossy());