Skip to content

Commit

Permalink
re_log: make setup for binaries an opt-in feature
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jan 16, 2024
1 parent 3de04b7 commit 7bf4ade
Show file tree
Hide file tree
Showing 44 changed files with 88 additions and 30 deletions.
23 changes: 23 additions & 0 deletions Cargo.lock

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

17 changes: 14 additions & 3 deletions crates/re_log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ version.workspace = true
all-features = true


[features]
default = []

## Feature to set up logging in binaries,
## i.e. from `main` or in a web-app.
setup = ["dep:env_logger", "dep:js-sys", "dep:wasm-bindgen"]


[dependencies]
log = { workspace = true, features = ["std"] }
log-once.workspace = true
Expand All @@ -26,9 +34,12 @@ tracing = { workspace = true, features = ["log"] }

# Native dependencies:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
env_logger = { workspace = true, features = ["auto-color", "humantime"] }
env_logger = { workspace = true, optional = true, features = [
"auto-color",
"humantime",
] }

# web dependencies:
[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys.workspace = true
wasm-bindgen.workspace = true
js-sys = { workspace = true, optional = true }
wasm-bindgen = { workspace = true, optional = true }
20 changes: 13 additions & 7 deletions crates/re_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
//! logging of the exact same message.
mod channel_logger;
mod multi_logger;
mod result_extensions;

#[cfg(feature = "setup")]
mod multi_logger;

#[cfg(feature = "setup")]
mod setup;

#[cfg(target_arch = "wasm32")]
#[cfg(all(feature = "setup", target_arch = "wasm32"))]
mod web_logger;

pub use log::{Level, LevelFilter};
Expand All @@ -32,11 +36,13 @@ pub use tracing::{debug, error, info, trace, warn};
// similar to how the log console in a browser will automatically suppress duplicates.
pub use log_once::{debug_once, error_once, info_once, log_once, trace_once, warn_once};

pub use {
channel_logger::*,
multi_logger::{add_boxed_logger, add_logger, MultiLoggerNotSetupError},
setup::*,
};
pub use channel_logger::*;

#[cfg(feature = "setup")]
pub use multi_logger::{add_boxed_logger, add_logger, MultiLoggerNotSetupError};

#[cfg(feature = "setup")]
pub use setup::*;

/// Re-exports of other crates.
pub mod external {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ re_data_ui.workspace = true
re_entity_db = { workspace = true, features = ["serde"] }
re_error.workspace = true
re_format.workspace = true
re_log.workspace = true
re_log = { workspace = true, features = ["setup"] }
re_log_encoding = { workspace = true, features = [
"decoder",
"encoder",
Expand Down
3 changes: 2 additions & 1 deletion tests/rust/log_benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ license.workspace = true
publish = false

[dependencies]
rerun = { path = "../../../crates/rerun" }
re_log = { workspace = true, features = ["setup"] }
re_tracing = { path = "../../../crates/re_tracing", features = ["server"] }
rerun = { path = "../../../crates/rerun" }

anyhow.workspace = true
clap = { workspace = true, features = ["derive"] }
Expand Down
1 change: 1 addition & 0 deletions tests/rust/plot_dashboard_stress/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license = "MIT OR Apache-2.0"
publish = false

[dependencies]
re_log = { workspace = true, features = ["setup"] }
rerun = { path = "../../../crates/rerun" }

anyhow = "1.0"
Expand Down
1 change: 1 addition & 0 deletions tests/rust/roundtrips/annotation_context/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rust-version.workspace = true
version.workspace = true

[dependencies]
re_log = { workspace = true, features = ["setup"] }
rerun = { path = "../../../../crates/rerun" }

anyhow.workspace = true
Expand Down
1 change: 0 additions & 1 deletion tests/rust/roundtrips/annotation_context/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use rerun::{
datatypes::{ClassDescription, KeypointPair},
external::re_log,
AnnotationContext, RecordingStream, Rgba32,
};

Expand Down
1 change: 1 addition & 0 deletions tests/rust/roundtrips/arrows2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rust-version.workspace = true
version.workspace = true

[dependencies]
re_log = { workspace = true, features = ["setup"] }
rerun = { path = "../../../../crates/rerun" }

anyhow.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion tests/rust/roundtrips/arrows2d/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Logs a `Arrows2D` archetype for roundtrip checks.
use rerun::{archetypes::Arrows2D, external::re_log, RecordingStream};
use rerun::{archetypes::Arrows2D, RecordingStream};

#[derive(Debug, clap::Parser)]
#[clap(author, version, about)]
Expand Down
1 change: 1 addition & 0 deletions tests/rust/roundtrips/arrows3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rust-version.workspace = true
version.workspace = true

[dependencies]
re_log = { workspace = true, features = ["setup"] }
rerun = { path = "../../../../crates/rerun" }

anyhow.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion tests/rust/roundtrips/arrows3d/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Logs a `Arrows3D` archetype for roundtrip checks.
use rerun::{archetypes::Arrows3D, external::re_log, RecordingStream};
use rerun::{archetypes::Arrows3D, RecordingStream};

#[derive(Debug, clap::Parser)]
#[clap(author, version, about)]
Expand Down
1 change: 1 addition & 0 deletions tests/rust/roundtrips/boxes2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rust-version.workspace = true
version.workspace = true

[dependencies]
re_log = { workspace = true, features = ["setup"] }
rerun = { path = "../../../../crates/rerun" }

anyhow.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion tests/rust/roundtrips/boxes2d/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Logs a `Box2D` archetype for roundtrip checks.
use rerun::{archetypes::Boxes2D, external::re_log, RecordingStream};
use rerun::{archetypes::Boxes2D, RecordingStream};

#[derive(Debug, clap::Parser)]
#[clap(author, version, about)]
Expand Down
1 change: 1 addition & 0 deletions tests/rust/roundtrips/boxes3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rust-version.workspace = true
version.workspace = true

[dependencies]
re_log = { workspace = true, features = ["setup"] }
rerun = { path = "../../../../crates/rerun" }

anyhow.workspace = true
Expand Down
1 change: 0 additions & 1 deletion tests/rust/roundtrips/boxes3d/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use rerun::{
archetypes::Boxes3D,
components::Rotation3D,
datatypes::{Quaternion, RotationAxisAngle},
external::re_log,
transform::Angle,
RecordingStream,
};
Expand Down
1 change: 1 addition & 0 deletions tests/rust/roundtrips/depth_image/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rust-version.workspace = true
version.workspace = true

[dependencies]
re_log = { workspace = true, features = ["setup"] }
rerun = { path = "../../../../crates/rerun" }

anyhow.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion tests/rust/roundtrips/depth_image/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Logs a `DepthImage` archetype for roundtrip checks.
use image::GrayImage;
use rerun::{archetypes::DepthImage, external::re_log, RecordingStream};
use rerun::{archetypes::DepthImage, RecordingStream};

#[derive(Debug, clap::Parser)]
#[clap(author, version, about)]
Expand Down
1 change: 1 addition & 0 deletions tests/rust/roundtrips/disconnected_space/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rust-version.workspace = true
version.workspace = true

[dependencies]
re_log = { workspace = true, features = ["setup"] }
rerun = { path = "../../../../crates/rerun" }

anyhow.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion tests/rust/roundtrips/disconnected_space/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Logs a `DisconnectedSpace` archetype for roundtrip checks.
use rerun::{archetypes::DisconnectedSpace, external::re_log, RecordingStream};
use rerun::{archetypes::DisconnectedSpace, RecordingStream};

#[derive(Debug, clap::Parser)]
#[clap(author, version, about)]
Expand Down
Loading

0 comments on commit 7bf4ade

Please sign in to comment.