Skip to content

Commit

Permalink
feat(rust): remove mentions of the ockam_log env. variable
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed Oct 30, 2024
1 parent bbdbfac commit 6970192
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 26 deletions.
1 change: 0 additions & 1 deletion examples/rust/get_started/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub async fn create_token(attribute_name: &str, attribute_value: &str) -> Result
"--attribute",
format!("{attribute_name}={attribute_value}").as_str(),
])
.env_remove("OCKAM_LOG") // make sure that OCKAM_LOG is not set, otherwise the output will contain more than the token
.env_remove("OCKAM_LOGGING") // make sure that OCKAM_LOGGING is not set, otherwise the output will contain more than the token
.output()
.map_err(|e| error(format!("could not run the `ockam project ticket` successfully: {e:?}")))?;
Expand Down
4 changes: 2 additions & 2 deletions implementations/rust/ockam/ockam_api/tests/latency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use ockam_transport_core::HostnamePort;
pub fn measure_message_latency_two_nodes() {
let runtime = Arc::new(Runtime::new().unwrap());
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::set_var("OCKAM_LOGGING", "false");

let result: ockam::Result<()> = runtime_cloned.block_on(async move {
let test_body = async move {
Expand Down Expand Up @@ -120,7 +120,7 @@ pub fn measure_message_latency_two_nodes() {
pub fn measure_buffer_latency_two_nodes_portal() {
let runtime = Arc::new(Runtime::new().unwrap());
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::set_var("OCKAM_LOGGING", "false");

let result: ockam::Result<()> = runtime_cloned.block_on(async move {
let test_body = async move {
Expand Down
8 changes: 4 additions & 4 deletions implementations/rust/ockam/ockam_api/tests/portals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn portal_node_goes_down_reconnect() {
let runtime = Arc::new(Runtime::new().unwrap());
let handle = runtime.handle();
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::set_var("OCKAM_LOGGING", "false");

let result: ockam::Result<()> = handle.block_on(async move {
let test_body = async move {
Expand Down Expand Up @@ -238,7 +238,7 @@ fn portal_low_bandwidth_connection_keep_working_for_60s() {
let runtime = Arc::new(Runtime::new().unwrap());
let handle = runtime.handle();
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::set_var("OCKAM_LOGGING", "false");

let result: ockam::Result<()> = handle.block_on(async move {
let test_body = async move {
Expand Down Expand Up @@ -359,7 +359,7 @@ fn portal_heavy_load_exchanged() {
let runtime = Arc::new(Runtime::new().unwrap());
let handle = runtime.handle();
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::set_var("OCKAM_LOGGING", "false");

let result: ockam::Result<()> = handle.block_on(async move {
let test_body = async move {
Expand Down Expand Up @@ -505,7 +505,7 @@ fn test_portal_payload_transfer(outgoing_disruption: Disruption, incoming_disrup
let runtime = Arc::new(Runtime::new().unwrap());
let handle = runtime.handle();
let runtime_cloned = runtime.clone();
std::env::set_var("OCKAM_LOG", "none");
std::env::set_var("OCKAM_LOGGING", "false");

let result: ockam::Result<_> = handle.block_on(async move {
let test_body = async move {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ CLI Behavior
- PAGER: a `string` that defines the pager to use for long help/usage messages. Defaults to `less`.

Logging
- OCKAM_LOG (deprecated, use OCKAM_LOGGING and OCKAM_LOG_LEVEL instead): a `string` that defines the verbosity of the logs when the `--verbose` argument is not passed: `info`, `warn`, `error`, `debug` or `trace`.
- OCKAM_LOGGING: set this variable to any value in order to enable logging.
- OCKAM_LOG_LEVEL: a `string` that defines the verbosity of the logs when the `--verbose` argument is not passed: `info`, `warn`, `error`, `debug` or `trace`. Default value: `debug`.
- OCKAM_LOG_FORMAT: a `string` that overrides the default format of the logs: `default`, `json`, or `pretty`. Default value: `default`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ fn output(mut cont: Container) -> TokenStream {
use core::time::Duration;
use ockam_core::{Error, errcode::{Origin, Kind}};
use #ockam_crate::{NodeBuilder, compat::{tokio::time::timeout, futures::FutureExt}};
// don't enable logs in tests by default
use ockam_core::env::get_env;

match get_env::<String>("OCKAM_LOG").unwrap() {
None => std::env::set_var("OCKAM_LOG", "none"),
Some(_) => (),
};

// we don't exit on a panic because we want to catch the panic and report it from within the test.
let (mut #ctx_ident, mut executor) = NodeBuilder::new().no_exit_on_panic().build();
Expand Down
2 changes: 1 addition & 1 deletion implementations/rust/ockam/ockam_node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn setup_tracing() {
use tracing_subscriber::{filter::LevelFilter, fmt, prelude::*, EnvFilter};
static ONCE: std::sync::Once = std::sync::Once::new();
ONCE.call_once(|| {
let filter = EnvFilter::try_from_env("OCKAM_LOG").unwrap_or_else(|_| {
let filter = EnvFilter::try_from_env("OCKAM_LOGGING").unwrap_or_else(|_| {
EnvFilter::default()
.add_directive(LevelFilter::INFO.into())
.add_directive("ockam_node=info".parse().unwrap())
Expand Down
5 changes: 3 additions & 2 deletions tools/docs/example_test_helper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! described by command lines.
//!
//! Processes have these environment variables set...
//! - `OCKAM_LOG=trace`
//! - `OCKAM_LOGGING=true; OCKAM_LOG_LEVEL=trace`
//!
//! Some functions will timeout if [`DEFAULT_TIMEOUT_MS`] milliseconds
//! pass. In particular [`CmdBuilder::run()`], but not [`CmdBuilder::spawn()`].
Expand Down Expand Up @@ -57,7 +57,8 @@ use tracing_subscriber::fmt::TestWriter;
use tracing_subscriber::{filter::LevelFilter, fmt, EnvFilter};

const POLL_MS: u32 = 250;
const ENVIRONMENT_VARIABLES: &[(&str, &str)] = &[("OCKAM_LOG", "trace")];
const ENVIRONMENT_VARIABLES: &[(&str, &str)] =
&[("OCKAM_LOGGING", "true"), ("OCKAM_LOG_LEVEL", "trace")];

/// Default timeout value in milliseconds.
pub const DEFAULT_TIMEOUT_MS: u32 = 180_000;
Expand Down
18 changes: 10 additions & 8 deletions tools/stress-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ Options:
To debug failures, you can use:

```
OCKAM_LOG=error stress-test run <config.toml> --log
OCKAM_LOGGING=true; OCKAM_LOG_LEVEL=error stress-test run <config.toml> --log
```

Sample configuration:

```
peak_portals = 20
peak_relays = 10
Expand All @@ -36,15 +37,16 @@ throughput = "1 mbits"
project = "/project/default"
```

| Parameter | Default | Description | Possible values |
|---------------|------------------|--------------------------------------------------------|------------------------------------------------------------------------------------------|
| peak_portals | 0 | Number of portals to create | positive integers, 1_000 is allowed |
| peak_relays | 0 | Number of relays to create, at least 1 is created | positive integers, 1_000 is allowed |
| ramp_up | 0 | Time, in seconds, to create all the portals and relays | positive integers |
| throughput | unlimited | Throughput to use for each portal | unlimited or positive integer followed by GBits,Mbits,Kbits,Bits, 1_000 Mbits is allowed |
| project | /project/default | Route to any project to test | Any route as long as it reaches a project |
| Parameter | Default | Description | Possible values |
|--------------|------------------|--------------------------------------------------------|------------------------------------------------------------------------------------------|
| peak_portals | 0 | Number of portals to create | positive integers, 1_000 is allowed |
| peak_relays | 0 | Number of relays to create, at least 1 is created | positive integers, 1_000 is allowed |
| ramp_up | 0 | Time, in seconds, to create all the portals and relays | positive integers |
| throughput | unlimited | Throughput to use for each portal | unlimited or positive integer followed by GBits,Mbits,Kbits,Bits, 1_000 Mbits is allowed |
| project | /project/default | Route to any project to test | Any route as long as it reaches a project |

Sample output:

```
| Elapsed | Portals | Relays | M. sent | M. recv | In-fli | B. sent | B. recv | Spe. sent | Spe. recv | M. OOO | Errors |
| 00s | 0 | 0 | 0 | 0 | 0 | 0 B | 0 B | 0.00 bps | 0.00 bps | 0 | 0 |
Expand Down

0 comments on commit 6970192

Please sign in to comment.