Skip to content

Commit 35fc49f

Browse files
committed
Enable the FFI/JNI logger even for INFO level messages
And add a separate `setup_logger` option for disabling logging entirely.
1 parent c31def7 commit 35fc49f

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

doc/libbwt.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ If bitcoind is running locally on the default port, at the default datadir locat
120120
- `poll_interval` - interval for polling new blocks/transactions from bitcoind in seconds (defaults to 5)
121121
- `tx_broadcast_cmd` - [custom command](https://github.com/shesek/bwt#scriptable-transaction-broadcast) for broadcasting transactions
122122
- `verbose` - verbosity level for stderr log messages (0-4, defaults to 0)
123+
- `require_addresses` - when disabled, the daemon will start even without any configured wallet addresses (defaults to true)
124+
- `setup_logger` - initialize logging via `pretty_env_logger` or `android_logger` (defaults to true)
123125
124126
#### Electrum
125127
- `electrum_addr` - bind address for electrum server (off by default)

src/config.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ pub struct Config {
354354
#[cfg_attr(feature = "cli", structopt(skip = true))]
355355
#[serde(default = "default_true")]
356356
pub require_addresses: bool,
357+
358+
// Not exposed as a CLI option, always set to true for CLI use
359+
#[cfg_attr(feature = "cli", structopt(skip = true))]
360+
#[serde(default = "default_true")]
361+
pub setup_logger: bool,
357362
}
358363

359364
impl Config {
@@ -455,6 +460,10 @@ impl Config {
455460

456461
#[cfg(any(feature = "pretty_env_logger", feature = "android_logger"))]
457462
pub fn setup_logger(&self) {
463+
if !self.setup_logger {
464+
return;
465+
}
466+
458467
#[cfg(feature = "pretty_env_logger")]
459468
let mut builder = apply_log_env(if self.timestamp {
460469
pretty_env_logger::formatted_timed_builder()
@@ -642,6 +651,7 @@ defaultable!(Config,
642651
initial_import_size=350,
643652
poll_interval=time::Duration::from_secs(5),
644653
require_addresses=true,
654+
setup_logger=true,
645655
)
646656
);
647657

src/interface.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ mod ffi {
3737

3838
let start = || -> Result<_> {
3939
let config: Config = serde_json::from_str(json_config).context("Invalid config")?;
40-
if config.verbose > 0 {
41-
// The verbosity level cannot be changed once enabled.
42-
INIT_LOGGER.call_once(|| config.setup_logger());
43-
}
40+
// The verbosity level cannot be changed once enabled.
41+
INIT_LOGGER.call_once(|| config.setup_logger());
4442

4543
let (progress_tx, progress_rx) = mpsc::channel();
4644
spawn_recv_progress_thread(progress_rx, callback_fn);
@@ -139,10 +137,8 @@ mod jni {
139137

140138
let start = || -> Result<_> {
141139
let config: Config = serde_json::from_str(&json_config).context("Invalid config")?;
142-
if config.verbose > 0 {
143-
// The verbosity level cannot be changed once enabled.
144-
INIT_LOGGER.call_once(|| config.setup_logger());
145-
}
140+
// The verbosity level cannot be changed once enabled.
141+
INIT_LOGGER.call_once(|| config.setup_logger());
146142

147143
let (progress_tx, progress_rx) = mpsc::channel();
148144
spawn_recv_progress_thread(progress_rx, jvm, callback_g);

0 commit comments

Comments
 (0)