Skip to content

Commit

Permalink
[difftest] deprecate '--log-level'
Browse files Browse the repository at this point in the history
  • Loading branch information
FanShupei committed Aug 27, 2024
1 parent 4102d7e commit b895010
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
10 changes: 7 additions & 3 deletions difftest/dpi_t1/src/dpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
use clap::Parser;
use std::ffi::{c_char, c_longlong};
use std::sync::Mutex;
use tracing::debug;
use tracing::{debug, error};

use crate::drive::Driver;
use crate::OfflineArgs;
use crate::OnlineArgs;
use svdpi::SvScope;

pub type SvBitVecVal = u32;
Expand Down Expand Up @@ -217,9 +217,13 @@ unsafe extern "C" fn axi_write_indexedAccessPort(

#[no_mangle]
unsafe extern "C" fn t1_cosim_init() {
let args = OfflineArgs::parse();
let args = OnlineArgs::parse();
dpi_common::setup_logger();

if args.log_level.is_some() {
error!("'--log-level' is deprecated, use 'RUST_LOG' env instead");
}

let scope = SvScope::get_current().expect("failed to get scope in t1_cosim_init");

let driver = Box::new(Driver::new(scope, &args));
Expand Down
5 changes: 2 additions & 3 deletions difftest/dpi_t1/src/drive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tracing::{debug, error, info, trace};

use crate::dpi::*;
use crate::get_t;
use crate::OfflineArgs;
use crate::OnlineArgs;
use svdpi::SvScope;

struct ShadowMem {
Expand Down Expand Up @@ -156,7 +156,7 @@ fn parse_range(input: &str) -> (u64, u64) {
}

impl Driver {
pub(crate) fn new(scope: SvScope, args: &OfflineArgs) -> Self {
pub(crate) fn new(scope: SvScope, args: &OnlineArgs) -> Self {
#[cfg(feature = "trace")]
let (dump_start, dump_end) = parse_range(&args.dump_range);

Expand All @@ -165,7 +165,6 @@ impl Driver {
&SpikeArgs {
elf_file: args.elf_file.clone(),
log_file: args.log_file.clone(),
log_level: args.log_level.clone(),
vlen: args.vlen,
dlen: args.dlen,
set: args.set.clone(),
Expand Down
8 changes: 4 additions & 4 deletions difftest/dpi_t1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod dpi;
pub mod drive;

#[derive(Parser)]
pub(crate) struct OfflineArgs {
pub(crate) struct OnlineArgs {
/// Path to the ELF file
#[arg(long)]
pub elf_file: PathBuf,
Expand All @@ -15,9 +15,9 @@ pub(crate) struct OfflineArgs {
#[arg(long)]
pub log_file: Option<PathBuf>,

/// Log level: trace, debug, info, warn, error
#[arg(long, default_value = "info")]
pub log_level: String,
/// deprecated, use 'RUST_LOG' instead
#[arg(long)]
pub log_level: Option<String>,

/// vlen config
#[arg(long, default_value = env!("DESIGN_VLEN"))]
Expand Down
22 changes: 15 additions & 7 deletions difftest/offline/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::path::PathBuf;

use clap::Parser;
use spike_rs::runner::{SpikeArgs, SpikeRunner};
use tracing::info;
use tracing_subscriber::{EnvFilter, FmtSubscriber};
use tracing::{error, info, level_filters::LevelFilter};
use tracing_subscriber::{filter::Directive, EnvFilter, FmtSubscriber};

use crate::difftest::Difftest;

Expand All @@ -22,9 +22,9 @@ pub struct Args {
#[arg(long)]
pub log_file: Option<PathBuf>,

/// Log level: trace, debug, info, warn, error
#[arg(long, default_value = "info")]
pub log_level: String,
/// deprecated, use 'RUST_LOG' instead
#[arg(long)]
pub log_level: Option<String>,

/// vlen config
#[arg(long, default_value = env!("DESIGN_VLEN"))]
Expand Down Expand Up @@ -65,10 +65,13 @@ fn main() -> anyhow::Result<()> {

setup_logger();

if args.log_level.is_some() {
error!("'--log-level' is deprecated, use 'RUST_LOG' env instead");
}

let args = SpikeArgs {
elf_file: args.elf_file,
log_file: args.log_file,
log_level: args.log_level,
vlen: args.vlen,
dlen: args.dlen,
set: args.set,
Expand All @@ -95,8 +98,13 @@ fn main() -> anyhow::Result<()> {
}

fn setup_logger() {
// default to WARN level
let env_filer = EnvFilter::builder()
.with_default_directive(LevelFilter::WARN.into())
.from_env_lossy();

let global_logger = FmtSubscriber::builder()
.with_env_filter(EnvFilter::from_default_env())
.with_env_filter(env_filer)
.without_time()
.with_target(false)
.compact()
Expand Down
3 changes: 0 additions & 3 deletions difftest/spike_rs/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ pub struct SpikeArgs {
/// Path to the log file
pub log_file: Option<PathBuf>,

/// Log level: trace, debug, info, warn, error
pub log_level: String,

/// vlen config
pub vlen: u32,

Expand Down

0 comments on commit b895010

Please sign in to comment.