Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set RUST_BACKTRACE by default #1143

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading