-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathlogger.rs
36 lines (28 loc) · 1.12 KB
/
logger.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
//! cargo run --example logger --release
use iota_client::{Client, Result};
#[tokio::main]
async fn main() -> Result<()> {
// Generates a client.log file with logs for debugging
let logger_output_config = fern_logger::LoggerOutputConfigBuilder::new()
.name("client.log")
.target_exclusions(&["h2", "hyper", "rustls"])
.level_filter(log::LevelFilter::Debug);
let config = fern_logger::LoggerConfig::build()
.with_output(logger_output_config)
.finish();
fern_logger::logger_init(config).unwrap();
// Take the node URL from command line argument or use one from env as default.
let node_url = std::env::args().nth(1).unwrap_or_else(|| {
// This example uses dotenv, which is not safe for use in production.
dotenv::dotenv().ok();
std::env::var("NODE_URL").unwrap()
});
// Create a client with that node.
let client = Client::builder().with_node(&node_url)?.finish()?;
// Get node info.
let info = client.get_info().await?;
println!("{info:#?}");
Ok(())
}