Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrohd committed Mar 25, 2024
1 parent 948c3cf commit 2b6e15c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 63 deletions.
35 changes: 8 additions & 27 deletions crates/Cargo.lock

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

37 changes: 4 additions & 33 deletions crates/marecchia-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "marecchia-core"
description = "WASM module for the Marecchia project"
version = "0.0.1"
version = "0.0.2"
license.workspace = true
authors.workspace = true
edition.workspace = true
Expand Down Expand Up @@ -33,35 +33,6 @@ wasm-bindgen = "^0.2.92"
wasm-bindgen-futures = "^0.4.42"
futures = { version = "0.3", default-features = false, features = ["alloc"] }
js-sys = "^0.3.69"
m3u8-rs = "^6.0"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing-wasm = "0.2.1"

[dependencies.web-sys]
version = "^0.3.69"
features = [
"Window",
"console",
"MessageEvent",
"Request",
"RequestInit",
"RequestMode",
"Response",
"RtcPeerConnection",
"RtcSignalingState",
"RtcSdpType",
"RtcSessionDescriptionInit",
"RtcPeerConnectionIceEvent",
"RtcIceCandidate",
"RtcDataChannel",
"RtcDataChannelEvent",
"WebSocket",
"BinaryType",
"Blob",
"ErrorEvent",
"FileReader",
"MessageEvent",
"ProgressEvent",
"WebSocket",
]
tracing = { version = "0.1.40", default-features = false, features = ["attributes"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["smallvec", "fmt", "ansi", "env-filter"] }
tracing-web = "0.1.3"
4 changes: 2 additions & 2 deletions crates/marecchia-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod http;
mod loader;
//mod http;
//mod loader;
mod p2p;
13 changes: 12 additions & 1 deletion crates/marecchia-core/src/p2p/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use libp2p::{
};
use libp2p_webrtc_websys as webrtc_websys;
use std::{num::NonZeroU8, str::FromStr, time::Duration};
use tracing_subscriber::{fmt::format::Pretty, prelude::*};
use tracing_web::{performance_layer, MakeWebConsoleWriter};
use wasm_bindgen::prelude::*;

use super::{
Expand All @@ -25,7 +27,16 @@ pub fn new_p2p_client(
stream_id: String,
secret_key_seed: Option<u8>,
) -> Result<P2PClient, ClientError> {
tracing_wasm::set_as_global_default();
let fmt_layer = tracing_subscriber::fmt::layer()
.with_ansi(false) // Only partially supported across browsers
.without_time() // std::time is not available in browsers, see note below
.with_writer(MakeWebConsoleWriter::new()); // write events to the console
let perf_layer = performance_layer().with_details_from_fields(Pretty::default());

tracing_subscriber::registry()
.with(fmt_layer)
.with(perf_layer)
.init(); // Install these as subscribers to tracing events

let namespace = Namespace::new(stream_id)?;

Expand Down

0 comments on commit 2b6e15c

Please sign in to comment.