add command line option to set log level

This commit is contained in:
Craig Raw 2021-03-01 16:32:11 +02:00
parent 6068666415
commit f369b3ad00
4 changed files with 13 additions and 1 deletions

View file

@ -43,6 +43,9 @@ Usage: sparrow [options]
Path to Sparrow home folder
--help, -h
Show usage
--level, -l
Set log level
Possible Values: [ERROR, WARN, INFO, DEBUG, TRACE]
--network, -n
Network to use
Possible Values: [mainnet, testnet, regtest, signet]

2
drongo

@ -1 +1 @@
Subproject commit faa8f71313ff102c9611f8a9265511029654a83c
Subproject commit b84aa2e7cb0c1f78fb36d610295ade0439e0df2a

View file

@ -2,6 +2,7 @@ package com.sparrowwallet.sparrow;
import com.beust.jcommander.Parameter;
import com.sparrowwallet.drongo.Network;
import org.slf4j.event.Level;
public class Args {
@Parameter(names = { "--dir", "-d" }, description = "Path to Sparrow home folder")
@ -10,6 +11,9 @@ public class Args {
@Parameter(names = { "--network", "-n" }, description = "Network to use")
public Network network;
@Parameter(names = { "--level", "-l" }, description = "Set log level")
public Level level;
@Parameter(names = { "--help", "-h" }, description = "Show usage", help = true)
public boolean help;
}

View file

@ -1,6 +1,7 @@
package com.sparrowwallet.sparrow;
import com.beust.jcommander.JCommander;
import com.sparrowwallet.drongo.Drongo;
import com.sparrowwallet.drongo.Network;
import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
@ -119,6 +120,10 @@ public class MainApp extends Application {
System.exit(0);
}
if(args.level != null) {
Drongo.setRootLogLevel(args.level);
}
if(args.dir != null) {
System.setProperty(APP_HOME_PROPERTY, args.dir);
getLogger().info("Using configured Sparrow home folder of " + args.dir);