Skip to content

Commit

Permalink
add logging option and switch to holochain_trace
Browse files Browse the repository at this point in the history
  • Loading branch information
pegahvaezi committed Oct 31, 2023
1 parent b7959b3 commit e90f513
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "holochain-runner"
version = "0.7.9"
version = "0.7.12"
description = "a Holochain runtime binary with key management, good defaults, and Status Update events. Suitable for development and production environments"
authors = ["Connor Turland <[email protected]>", "Wesley Finck <[email protected]>", "Karl Bonnici <[email protected]>"]
license = "CAL-1.0"
Expand All @@ -24,6 +24,7 @@ holochain_p2p = "0.2.3-beta-rc.0"
holochain_types = "0.2.3-beta-rc.0"
holochain_zome_types = "0.2.3-beta-rc.0"
holochain_keystore = "0.2.3-beta-rc.0"
holochain_trace = "0.2.2"
holochain = "0.2.3-beta-rc.1"
hdk = "0.2.3-beta-rc.0"
contrafact = "0.2.0-rc.1"
Expand Down
7 changes: 4 additions & 3 deletions src/embedded_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use holochain::conductor::{api::error::ConductorApiResult, Conductor, ConductorH
use holochain_p2p::kitsune_p2p::dependencies::url2::Url2;
use holochain_types::app::InstalledAppId;
use holochain_zome_types::NetworkSeed;
use observability::Output;
use holochain_trace::Output;
use std::path::PathBuf;
use tokio::sync::mpsc;
use tracing::*;
Expand All @@ -25,15 +25,16 @@ pub struct HcConfig {
pub bootstrap_url: Url2,
pub network_seed: Option<NetworkSeed>,
pub gossip_arc_clamping: String,
pub logging: Output,
}

pub async fn async_main(passphrase: sodoken::BufRead, hc_config: HcConfig) -> ConductorHandle {
// Sets up a human-readable panic message with a request for bug reports
// See https://docs.rs/human-panic/1.0.3/human_panic/
human_panic::setup_panic!();
// take in command line arguments
observability::init_fmt(Output::Log).expect("Failed to start contextual logging");
debug!("observability initialized");
holochain_trace::init_fmt(hc_config.logging).expect("Failed to start contextual logging");
debug!("holochain_trace initialized");
// Uncomment this to get regular networking info status updates in the logs
// kitsune_p2p_types::metrics::init_sys_info_poll();
if !hc_config.datastore_path.as_path().exists() {
Expand Down
14 changes: 14 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use embedded_runner::{async_main, HcConfig};
use emit::StateSignal;
use holochain::conductor::manager::handle_shutdown;
use holochain_p2p::kitsune_p2p::dependencies::url2::Url2;
use holochain_trace::Output;
use std::env;
use std::path::PathBuf;
use structopt::StructOpt;
Expand Down Expand Up @@ -92,6 +93,18 @@ or none of it (empty). Default behavior is to auto-adjust your gossip arc based
help = "Path to a local .env file containing a LAIR_PASSWORD variable"
)]
env_path: Option<PathBuf>,

#[structopt(
long,
help = "Outputs structured json from logging:
- None: No logging at all (fastest)
- Log: Output logs to stdout with spans (human readable)
- Compact: Same as Log but with less information
- Json: Output logs as structured json (machine readable)
",
default_value = "Log"
)]
logging: Output,
}

fn main() {
Expand Down Expand Up @@ -165,6 +178,7 @@ fn main() {
bootstrap_url: opt.bootstrap_url,
network_seed: opt.network_seed,
gossip_arc_clamping: opt.gossip_arc_clamping,
logging: opt.logging,
},
)
.await;
Expand Down

0 comments on commit e90f513

Please sign in to comment.