Skip to content

Commit

Permalink
[hemu] add --log argument to specify the log level
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf committed May 9, 2024
1 parent cd399e8 commit 1d0c9ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/log.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use tracing::Level;
use tracing_subscriber::{EnvFilter, FmtSubscriber};

pub fn log_trace() {
pub fn log_trace(level: Level) {
let global_logger = FmtSubscriber::builder()
.with_env_filter(EnvFilter::from_default_env())
.with_max_level(Level::TRACE)
.with_max_level(level)
.without_time()
.with_target(false)
.compact()
Expand Down
15 changes: 13 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,28 @@ struct Args {
#[arg(short = 'f', long = "file")]
file: Option<PathBuf>,

/// Difftest
#[arg(short, long, default_value = "info")]
log: String,

/// Difftest
#[arg(short, long)]
diff: bool,

/// Enable tui
#[arg(short, long)]
tui: bool
}

/// Main function of RISC-V emulator for the CLI version.
fn main() -> anyhow::Result<()> {
log_trace();

let args = Args::parse();

// Set the log level.
// "error", "warn", "info", "debug", "trace"
let level = args.log.parse()?;
log_trace(level);

// Read the kernel bin(after objcopy) and the disk image.
let mut kernel_file = File::open(args.kernel)?;
let mut kernel_data = Vec::new();
Expand Down

0 comments on commit 1d0c9ca

Please sign in to comment.