Skip to content

Commit

Permalink
move logging to separate crate
Browse files Browse the repository at this point in the history
  • Loading branch information
master-of-zen committed Dec 28, 2024
1 parent 0b58919 commit 12e4a23
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 62 deletions.
26 changes: 18 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ members = [
"av1an-output",
"av1an-input",
"av1an-cli",
"av1an-logging",
]
resolver = "2"

[workspace.package]
version = "0.4.4"
version = "0.4.5"
rust-version = "1.83"
edition = "2021"
authors = ["Zen <[email protected]>"]
Expand Down
16 changes: 3 additions & 13 deletions av1an-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ rust-version.workspace = true
edition.workspace = true
version.workspace = true
authors.workspace = true
description = """
Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding [Core library]
"""
description = "Cross-platform command-line AV1 / VP9 / HEVC / H264 encoding framework with per scene quality encoding [Core library]"
repository.workspace = true
keywords = ["video"]
categories = ["command-line-utilities"]
license = "GPL-3.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing-appender.workspace = true
tracing.workspace = true
av1an-logging = { path = "../av1an-logging", version = "0.4.5" }
log = "0.4.14"
arrayvec = "0.7.2"
av-format = "0.7.0"
Expand Down Expand Up @@ -52,14 +47,10 @@ simdutf8 = "0.1.3"
parking_lot = "0.12.0"
cfg-if = "1.0.0"
nom = "7.1.1"
# TODO: move all of this CLI stuff to av1an-cli
ansi_term = "0.12.1"

tokio = { version = "1.28", features = ["full"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing = { workspace = true }

# TODO: https://github.com/elast0ny/affinity/issues/2
# update this when macos support is implemented
[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
affinity = "0.1.2"

Expand All @@ -73,7 +64,6 @@ package = "ffmpeg-the-third"
version = "2.0.1"
features = ["serialize"]


[dependencies.vapoursynth]
version = "0.4.0"
features = ["vsscript-functions", "vapoursynth-functions"]
Expand Down
2 changes: 1 addition & 1 deletion av1an-core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ impl Av1anContext {

let num_frames = num_frames(Path::new(file))?;

let mut chunk = Chunk {
let chunk = Chunk {
temp: self.args.temp.clone(),
input: Input::Video {
path: PathBuf::from(file)
Expand Down
6 changes: 1 addition & 5 deletions av1an-core/src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use itertools::chain;
use serde::{Deserialize, Serialize};
use thiserror::Error;

use crate::{
into_array,
into_vec,
};
use crate::{into_array, into_vec};

const NULL: &str = if cfg!(windows) { "nul" } else { "/dev/null" };

Expand Down Expand Up @@ -65,7 +62,6 @@ impl Display for Encoder {
}

impl Encoder {
/// Composes 1st pass command for 1 pass encoding
pub fn compose_1_1_pass(
self,
params: Vec<String>,
Expand Down
1 change: 0 additions & 1 deletion av1an-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub mod concat;
pub mod context;
pub mod encoder;
pub mod ffmpeg;
pub mod logging;
pub(crate) mod parse;
pub mod progress_bar;
pub mod scene_detect;
Expand Down
13 changes: 13 additions & 0 deletions av1an-logging/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "av1an-logging"
version.workspace = true
edition.workspace = true
authors.workspace = true
description = "Logging functionality for av1an video encoder"
repository.workspace = true

[dependencies]
tracing = { workspace = true }
tracing-appender = { workspace = true }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
once_cell = "1.8.0"
62 changes: 31 additions & 31 deletions av1an-core/src/logging.rs → av1an-logging/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,37 +105,37 @@ pub fn init_logging() {

// Create our subscriber with correctly ordered layers
let subscriber = tracing_subscriber::registry()
// Console output layer
.with(
fmt::Layer::new()
// First configure all formatting
.with_ansi(std::io::stderr().is_terminal())
.with_target(true)
.with_thread_ids(false)
.with_file(false)
.with_line_number(false)
.with_level(true)
// Set the writer
.with_writer(std::io::stdout)
// Apply the filter last
.with_filter(console_filter),
)
// File output layer
.with(
fmt::Layer::new()
// First configure all formatting
.with_ansi(false)
.with_target(true)
.with_thread_ids(true)
.with_thread_names(true)
.with_file(true)
.with_line_number(true)
.with_level(true)
// Set the writer
.with_writer(non_blocking)
// Apply the filter last
.with_filter(file_filter),
);
// Console output layer
.with(
fmt::Layer::new()
// First configure all formatting
.with_ansi(std::io::stderr().is_terminal())
.with_target(true)
.with_thread_ids(false)
.with_file(false)
.with_line_number(false)
.with_level(true)
// Set the writer
.with_writer(std::io::stdout)
// Apply the filter last
.with_filter(console_filter),
)
// File output layer
.with(
fmt::Layer::new()
// First configure all formatting
.with_ansi(false)
.with_target(true)
.with_thread_ids(true)
.with_thread_names(true)
.with_file(true)
.with_line_number(true)
.with_level(true)
// Set the writer
.with_writer(non_blocking)
// Apply the filter last
.with_filter(file_filter),
);

// Set as global default
tracing::subscriber::set_global_default(subscriber)
Expand Down
3 changes: 2 additions & 1 deletion av1an/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[package]
name = "av1an"

authors.workspace = true
version.workspace = true
description = """
Expand All @@ -18,7 +19,7 @@ name = "av1an"
path = "src/main.rs"

[dependencies]

av1an-logging = { path = "../av1an-logging" }
shlex = "1.3.0"
path_abs = "0.5.1"
anyhow = "1.0.42"
Expand Down
2 changes: 1 addition & 1 deletion av1an/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use av1an_core::{
ffmpeg,
hash_path,
into_vec,
logging::init_logging,
settings::{EncodeArgs, InputPixelFormat, PixelFormat},
util::read_in_dir,
vapoursynth,
Expand All @@ -26,6 +25,7 @@ use av1an_core::{
SplitMethod,
Verbosity,
};
use av1an_logging::init_logging;
use clap::{value_parser, Parser};
use path_abs::{PathAbs, PathInfo};
use tracing::{instrument, warn};
Expand Down
Loading

0 comments on commit 12e4a23

Please sign in to comment.