Skip to content

Commit

Permalink
feat(crypto-helper): replace log crate with tracing;
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestTvarynka committed Aug 23, 2024
1 parent 4c73780 commit 5f87462
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 24 deletions.
147 changes: 130 additions & 17 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ wasm-bindgen = "0.2"
web-sys = { version = "0.3", features = ["Window"] }

# logging
wasm-logger = "0.2"
log = "0.4"
tracing-web = "0.1"
tracing-subscriber = { version = "0.3", default-features = false, features = ["std", "fmt", "time", "ansi", "env-filter"] }
tracing = "0.1"

# utils
hex = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion crates/asn1-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ prop-strategies = { path = "../prop-strategies" }
proptest = "1.2.0"

[dependencies]
log = "0.4.20"
tracing = "0.1"
num-bigint-dig = { version = "0.8.4", default-features = false }
num-traits = { version = "0.2.17", default-features = false }
oid = { version = "0.2.1", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/asn1-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod macros;

#[allow(unused_imports)]
#[macro_use]
extern crate log;
extern crate tracing;

mod asn1;
mod constructors;
Expand Down
15 changes: 14 additions & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
use crypto_helper::App;
use tracing_subscriber::fmt::format::Pretty;
use tracing_subscriber::prelude::*;
use tracing_subscriber::EnvFilter;
use tracing_web::{performance_layer, MakeWebConsoleWriter};

fn main() {
wasm_logger::init(wasm_logger::Config::default());
let fmt_layer = tracing_subscriber::fmt::layer()
.with_ansi(false)
.without_time()
.with_writer(MakeWebConsoleWriter::new());
let perf_layer = performance_layer().with_details_from_fields(Pretty::default());
tracing_subscriber::registry()
.with(fmt_layer)
.with(perf_layer)
.with(EnvFilter::from_default_env())
.init();

yew::Renderer::<App>::new().render();
}
15 changes: 14 additions & 1 deletion src/bin/worker.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
use crypto_helper::diff::{DiffTask, JsonCodec};
use tracing_subscriber::fmt::format::Pretty;
use tracing_subscriber::prelude::*;
use tracing_subscriber::EnvFilter;
use tracing_web::{performance_layer, MakeWebConsoleWriter};
use yew_agent::Registrable;

fn main() {
wasm_logger::init(wasm_logger::Config::default());
let fmt_layer = tracing_subscriber::fmt::layer()
.with_ansi(false)
.without_time()
.with_writer(MakeWebConsoleWriter::new());
let perf_layer = performance_layer().with_details_from_fields(Pretty::default());
tracing_subscriber::registry()
.with(fmt_layer)
.with(perf_layer)
.with(EnvFilter::from_default_env())
.init();

DiffTask::registrar().encoding::<JsonCodec>().register();
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[macro_use]
extern crate log;
extern crate tracing;

mod about;
mod asn1;
Expand Down

0 comments on commit 5f87462

Please sign in to comment.