Skip to content

Commit

Permalink
Merge pull request #1143 from mintlayer/enable_rust_backtrace
Browse files Browse the repository at this point in the history
Set RUST_BACKTRACE by default
  • Loading branch information
pavel-kokolemin committed Aug 7, 2023
2 parents 72b0e1c + 89d9751 commit 1375c9e
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ The logging of mintlayer-core is configured via the `RUST_LOG` environment varia
Here are the commands as recommended for different scenarios:

For normal operation
- Node daemon: `RUST_BACKTRACE=full RUST_LOG=info cargo run --bin node-daemon -- testnet 2>&1 | tee ../mintlayer.log`
- CLI Wallet: `RUST_BACKTRACE=full RUST_LOG=info cargo run --bin wallet-cli -- --network testnet 2>&1 | tee ../wallet-cli.log`
- GUI: `RUST_BACKTRACE=full RUST_LOG=info cargo run --bin node-gui 2>&1 | tee ../node-gui.log`
- Node daemon: `RUST_LOG=info cargo run --bin node-daemon -- testnet 2>&1 | tee ../mintlayer.log`
- CLI Wallet: `RUST_LOG=info cargo run --bin wallet-cli -- --network testnet 2>&1 | tee ../wallet-cli.log`
- GUI: `RUST_LOG=info cargo run --bin node-gui 2>&1 | tee ../node-gui.log`

For heavy debugging operation
- Node daemon: `RUST_BACKTRACE=full RUST_LOG=debug cargo run --bin node-daemon -- testnet 2>&1 | tee ../mintlayer.log`
- CLI Wallet: `RUST_BACKTRACE=full RUST_LOG=debug cargo run --bin wallet-cli -- --network testnet 2>&1 | tee ../wallet-cli.log`
- GUI: `RUST_BACKTRACE=full RUST_LOG=debug cargo run --bin node-gui 2>&1 | tee ../node-gui.log`
- Node daemon: `RUST_LOG=debug cargo run --bin node-daemon -- testnet 2>&1 | tee ../mintlayer.log`
- CLI Wallet: `RUST_LOG=debug cargo run --bin wallet-cli -- --network testnet 2>&1 | tee ../wallet-cli.log`
- GUI: `RUST_LOG=debug cargo run --bin node-gui 2>&1 | tee ../node-gui.log`
2 changes: 2 additions & 0 deletions dns_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ async fn run(config: Arc<DnsServerConfig>) -> Result<Never, error::DnsServerErro

#[tokio::main]
async fn main() {
utils::rust_backtrace::enable();

logging::init_logging::<std::path::PathBuf>(None);

let config = Arc::new(DnsServerConfig::parse());
Expand Down
1 change: 1 addition & 0 deletions node-daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rust-version.workspace = true
[dependencies]
logging = { path = "../logging" }
node-lib = { path = "../node-lib/" }
utils = { path = "../utils" }

anyhow.workspace = true
tokio = { workspace = true, default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions node-daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub async fn run() -> anyhow::Result<()> {

#[tokio::main]
async fn main() {
utils::rust_backtrace::enable();

run().await.unwrap_or_else(|err| {
eprintln!("Mintlayer node launch failed: {err:?}");
std::process::exit(1)
Expand Down
2 changes: 2 additions & 0 deletions node-gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ use main_window::{MainWindow, MainWindowMessage};
use tokio::sync::mpsc::UnboundedReceiver;

pub fn main() -> iced::Result {
utils::rust_backtrace::enable();

MintlayerNodeGUI::run(Settings {
id: Some("mintlayer-gui".to_owned()),
antialiasing: true,
Expand Down
1 change: 1 addition & 0 deletions utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub mod maybe_encrypted;
pub mod newtype;
pub mod once_destructor;
pub mod qrcode;
pub mod rust_backtrace;
pub mod set_flag;
pub mod shallow_clone;
pub mod tap_error_log;
Expand Down
21 changes: 21 additions & 0 deletions utils/src/rust_backtrace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2023 RBB S.r.l
// opensource@mintlayer.org
// SPDX-License-Identifier: MIT
// Licensed under the MIT License;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://github.com/mintlayer/mintlayer-core/blob/master/LICENSE
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/// Set the `RUST_BACKTRACE` environment variable to `full` if it's not already set
pub fn enable() {
if std::env::var("RUST_BACKTRACE").is_err() {
std::env::set_var("RUST_BACKTRACE", "full");
}
}
1 change: 1 addition & 0 deletions wallet/wallet-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ rust-version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
utils = { path = "../../utils" }
wallet-cli-lib = { path = "../wallet-cli-lib" }

clap = { version = "4", features = ["derive"] }
Expand Down
2 changes: 2 additions & 0 deletions wallet/wallet-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use wallet_cli_lib::{

#[tokio::main]
async fn main() {
utils::rust_backtrace::enable();

if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");
}
Expand Down

0 comments on commit 1375c9e

Please sign in to comment.