rice_proto/
lib.rs

1// Copyright (C) 2020 Matthew Waters <matthew@centricular.com>
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9#[macro_use]
10extern crate tracing;
11
12pub mod agent;
13pub mod candidate;
14pub mod component;
15mod conncheck;
16mod gathering;
17pub mod stream;
18
19#[cfg(feature = "capi")]
20pub mod capi;
21
22#[cfg(test)]
23pub(crate) mod tests {
24    use tracing::subscriber::DefaultGuard;
25    use tracing_subscriber::layer::SubscriberExt;
26    use tracing_subscriber::Layer;
27
28    use super::*;
29
30    pub fn test_init_log() -> DefaultGuard {
31        let level_filter = std::env::var("RICE_LOG")
32            .or(std::env::var("RUST_LOG"))
33            .ok()
34            .and_then(|var| var.parse::<tracing_subscriber::filter::Targets>().ok())
35            .unwrap_or(
36                tracing_subscriber::filter::Targets::new().with_default(tracing::Level::TRACE),
37            );
38        let registry = tracing_subscriber::registry().with(
39            tracing_subscriber::fmt::layer()
40                .with_file(true)
41                .with_line_number(true)
42                .with_level(true)
43                .with_target(false)
44                .with_test_writer()
45                .with_filter(level_filter),
46        );
47        tracing::subscriber::set_default(registry)
48    }
49}