diff --git a/av1an-core/src/broker.rs b/av1an-core/src/broker.rs index 91c50b16..3a8a9d7a 100644 --- a/av1an-core/src/broker.rs +++ b/av1an-core/src/broker.rs @@ -99,7 +99,7 @@ impl Display for EncoderCrash { impl<'a> Broker<'a> { /// Main encoding loop. set_thread_affinity may be ignored if the value is invalid. - #[tracing::instrument] + #[tracing::instrument(skip(self))] pub fn encoding_loop(self, tx: Sender<()>, set_thread_affinity: Option) { if !self.chunk_queue.is_empty() { let (sender, receiver) = crossbeam_channel::bounded(self.chunk_queue.len()); @@ -165,7 +165,7 @@ impl<'a> Broker<'a> { } } - #[tracing::instrument] + #[tracing::instrument(skip(self))] fn encode_chunk(&self, chunk: &mut Chunk, worker_id: usize) -> Result<(), Box> { let st_time = Instant::now(); diff --git a/av1an-core/src/concat.rs b/av1an-core/src/concat.rs index d5b1dae0..bb4b04ae 100644 --- a/av1an-core/src/concat.rs +++ b/av1an-core/src/concat.rs @@ -36,6 +36,7 @@ impl Display for ConcatMethod { } } +#[tracing::instrument] pub fn sort_files_by_filename(files: &mut [PathBuf]) { files.sort_unstable_by_key(|x| { // If the temp directory follows the expected format of 00000.ivf, 00001.ivf, etc., @@ -49,6 +50,7 @@ pub fn sort_files_by_filename(files: &mut [PathBuf]) { }); } +#[tracing::instrument] pub fn ivf(input: &Path, out: &Path) -> anyhow::Result<()> { let mut files: Vec = read_in_dir(input)?.collect(); @@ -137,6 +139,7 @@ pub fn ivf(input: &Path, out: &Path) -> anyhow::Result<()> { Ok(()) } +#[tracing::instrument] fn read_encoded_chunks(encode_dir: &Path) -> anyhow::Result> { Ok( fs::read_dir(encode_dir) @@ -145,6 +148,7 @@ fn read_encoded_chunks(encode_dir: &Path) -> anyhow::Result> { ) } +#[tracing::instrument] pub fn mkvmerge( temp_dir: &Path, output: &Path, @@ -222,6 +226,7 @@ pub fn mkvmerge( } /// Create mkvmerge options.json +#[tracing::instrument] pub fn mkvmerge_options_json( num: usize, encoder: Encoder, @@ -243,6 +248,7 @@ pub fn mkvmerge_options_json( } /// Concatenates using ffmpeg (does not work with x265) +#[tracing::instrument] pub fn ffmpeg(temp: &Path, output: &Path) -> anyhow::Result<()> { fn write_concat_file(temp_folder: &Path) -> anyhow::Result<()> { let concat_file = temp_folder.join("concat"); diff --git a/av1an-core/src/context.rs b/av1an-core/src/context.rs index e3dd5897..22e2f1ad 100644 --- a/av1an-core/src/context.rs +++ b/av1an-core/src/context.rs @@ -50,6 +50,8 @@ pub struct Av1anContext { } impl Av1anContext { + + #[tracing::instrument] pub fn new(mut args: EncodeArgs) -> anyhow::Result { args.validate()?; let mut this = Self { @@ -1168,7 +1170,7 @@ impl Av1anContext { output_ext: output_ext.to_owned(), index, start_frame: 0, - end_frame: num_frames, + end_frame: num_frames, frame_rate, video_params: overrides.as_ref().map_or_else( || self.args.video_params.clone(), diff --git a/av1an-core/src/encoder.rs b/av1an-core/src/encoder.rs index dbfb5638..2c978b67 100644 --- a/av1an-core/src/encoder.rs +++ b/av1an-core/src/encoder.rs @@ -32,6 +32,7 @@ pub enum Encoder { x265, } +#[tracing::instrument] pub(crate) fn parse_svt_av1_version(version: &[u8]) -> Option<(u32, u32, u32)> { let v_idx = memchr::memchr(b'v', version)?; let s = version.get(v_idx + 1..)?; diff --git a/av1an-core/src/logging.rs b/av1an-core/src/logging.rs index f430ad97..2a25d746 100644 --- a/av1an-core/src/logging.rs +++ b/av1an-core/src/logging.rs @@ -15,10 +15,10 @@ use tracing_subscriber::{fmt, prelude::*, EnvFilter}; /// /// This function will panic if it fails to initialize the global logger. pub fn init_logging() { - let rust_log = env::var("RUST_LOG").unwrap_or_else(|_| "INFO".to_string()); + let rust_log = env::var("RUST_LOG").unwrap_or_else(|_| "ERROR".to_string()); // Set up daily rotating file appender - let file_appender = RollingFileAppender::new(Rotation::DAILY, "logs", "application.log"); + let file_appender = RollingFileAppender::new(Rotation::DAILY, "logs", "av1an.log"); let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender); diff --git a/av1an/src/main.rs b/av1an/src/main.rs index 248daac8..1d4da4cd 100644 --- a/av1an/src/main.rs +++ b/av1an/src/main.rs @@ -547,6 +547,8 @@ pub struct CliOpts { } impl CliOpts { + + #[tracing::instrument] pub fn target_quality_params( &self, temp_dir: String, @@ -624,6 +626,7 @@ pub(crate) fn resolve_file_paths(path: &Path) -> anyhow::Result anyhow::Result> { let input_paths = &*args.input; @@ -879,49 +882,11 @@ pub fn run() -> anyhow::Result<()> { let cli_args = CliOpts::parse(); - let log_level = cli_args.log_level; + //let log_level = cli_args.log_level; let args = parse_cli(cli_args)?; - let log = LogSpecBuilder::new() - .default(LevelFilter::Error) - .module("av1an", log_level) - .module("av1an_cli", log_level) - .module("av1an_core", log_level) - .module( - "rav1e::scenechange", - match log_level { - LevelFilter::Trace => LevelFilter::Debug, - LevelFilter::Debug => LevelFilter::Info, - other => other, - }, - ) - .build(); - - // Note that with all write modes except WriteMode::Direct (which is the default) - // you should keep the LoggerHandle alive up to the very end of your program, - // because it will, in its Drop implementation, flush all writers to ensure that - // all buffered log lines are flushed before the program terminates, - // and then it calls their shutdown method. - let logger = Logger::with(log) - .log_to_file_and_writer( - // UGLY: take first or the files for log path - FileSpec::try_from(PathAbs::new(&args[0].log_file)?)?, - Box::new(StderrLogger { - // UGLY: take first or the files for verbosity - level: match args[0].verbosity { - Verbosity::Quiet => Level::Warn, - Verbosity::Normal | Verbosity::Verbose => Level::Info, - }, - }), - ) - .start()?; for arg in args { - // Change log file - let new_log_file = FileSpec::try_from(PathAbs::new(&arg.log_file)?)?; - let _ = - &logger.reset_flw(&flexi_logger::writers::FileLogWriter::builder(new_log_file).append())?; - Av1anContext::new(arg)?.encode_file()?; }