mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Add prog arg for log level
This commit is contained in:
parent
5535ee3167
commit
ed67b8d6b1
@ -84,8 +84,8 @@ public class Log {
|
||||
logbackLogger.addAppender(errorAppender);*/
|
||||
}
|
||||
|
||||
public static void setLevel(boolean useDetailedLogging) {
|
||||
logbackLogger.setLevel(useDetailedLogging ? Level.TRACE : Level.WARN);
|
||||
public static void setLevel(Level logLevel) {
|
||||
logbackLogger.setLevel(logLevel);
|
||||
}
|
||||
|
||||
public static void traceCall() {
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package io.bitsquare.app;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import io.bitsquare.BitsquareException;
|
||||
import io.bitsquare.btc.BitcoinNetwork;
|
||||
import io.bitsquare.btc.UserAgent;
|
||||
@ -59,8 +60,8 @@ public class BitsquareEnvironment extends StandardEnvironment {
|
||||
public static final String APP_DATA_DIR_KEY = "app.data.dir";
|
||||
public static final String DEFAULT_APP_DATA_DIR = appDataDir(DEFAULT_USER_DATA_DIR, DEFAULT_APP_NAME);
|
||||
|
||||
public static final String APP_DATA_DIR_CLEAN_KEY = "app.data.dir.clean";
|
||||
public static final String DEFAULT_APP_DATA_DIR_CLEAN = "false";
|
||||
public static final String LOG_LEVEL_KEY = "log.level";
|
||||
public static final String LOG_LEVEL_DEFAULT = (DevFlags.STRESS_TEST_MODE || DevFlags.DEV_MODE) ? Level.TRACE.levelStr : Level.WARN.levelStr;
|
||||
|
||||
static final String BITSQUARE_COMMANDLINE_PROPERTY_SOURCE_NAME = "bitsquareCommandLineProperties";
|
||||
static final String BITSQUARE_APP_DIR_PROPERTY_SOURCE_NAME = "bitsquareAppDirProperties";
|
||||
@ -74,6 +75,7 @@ public class BitsquareEnvironment extends StandardEnvironment {
|
||||
private final String userDataDir;
|
||||
private final String appDataDir;
|
||||
private final String btcNetworkDir;
|
||||
private final String logLevel;
|
||||
private BitcoinNetwork bitcoinNetwork;
|
||||
|
||||
public BitsquareEnvironment(OptionSet options) {
|
||||
@ -123,6 +125,10 @@ public class BitsquareEnvironment extends StandardEnvironment {
|
||||
(String) commandLineProperties.getProperty(APP_DATA_DIR_KEY) :
|
||||
appDataDir(userDataDir, appName);
|
||||
|
||||
logLevel = commandLineProperties.containsProperty(LOG_LEVEL_KEY) ?
|
||||
(String) commandLineProperties.getProperty(LOG_LEVEL_KEY) :
|
||||
LOG_LEVEL_DEFAULT;
|
||||
|
||||
MutablePropertySources propertySources = this.getPropertySources();
|
||||
propertySources.addFirst(commandLineProperties);
|
||||
try {
|
||||
@ -178,7 +184,7 @@ public class BitsquareEnvironment extends StandardEnvironment {
|
||||
|
||||
{
|
||||
setProperty(APP_DATA_DIR_KEY, appDataDir);
|
||||
setProperty(APP_DATA_DIR_CLEAN_KEY, DEFAULT_APP_DATA_DIR_CLEAN);
|
||||
setProperty(LOG_LEVEL_KEY, logLevel);
|
||||
|
||||
setProperty(APP_NAME_KEY, appName);
|
||||
setProperty(USER_DATA_DIR_KEY, userDataDir);
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package io.bitsquare.app;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
@ -72,6 +73,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static io.bitsquare.app.BitsquareEnvironment.APP_NAME_KEY;
|
||||
import static io.bitsquare.app.BitsquareEnvironment.LOG_LEVEL_KEY;
|
||||
|
||||
public class BitsquareApp extends Application {
|
||||
private static final Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(BitsquareApp.class);
|
||||
@ -97,14 +99,13 @@ public class BitsquareApp extends Application {
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
BitsquareApp.primaryStage = stage;
|
||||
|
||||
String logPath = Paths.get(env.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY), "bitsquare").toString();
|
||||
|
||||
String logPath = Paths.get(env.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY), "bitsquare").toString();
|
||||
Log.setup(logPath);
|
||||
log.info("Log files under: " + logPath);
|
||||
Version.printVersion();
|
||||
Utilities.printSysInfo();
|
||||
Log.setLevel(!DevFlags.IS_RELEASE_VERSION && !DevFlags.STRESS_TEST_MODE);
|
||||
Log.setLevel(Level.toLevel(env.getRequiredProperty(LOG_LEVEL_KEY)));
|
||||
|
||||
UserThread.setExecutor(Platform::runLater);
|
||||
UserThread.setTimerClass(UITimer.class);
|
||||
|
@ -34,7 +34,6 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static io.bitsquare.app.BitsquareEnvironment.*;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class BitsquareAppMain extends BitsquareExecutable {
|
||||
private static final Logger log = LoggerFactory.getLogger(BitsquareAppMain.class);
|
||||
@ -94,10 +93,8 @@ public class BitsquareAppMain extends BitsquareExecutable {
|
||||
.withRequiredArg();
|
||||
parser.accepts(APP_DATA_DIR_KEY, description("Application data directory", DEFAULT_APP_DATA_DIR))
|
||||
.withRequiredArg();
|
||||
parser.acceptsAll(asList(APP_DATA_DIR_CLEAN_KEY, "clean"),
|
||||
description("Clean application data directory", DEFAULT_APP_DATA_DIR_CLEAN))
|
||||
.withRequiredArg()
|
||||
.ofType(boolean.class);
|
||||
parser.accepts(LOG_LEVEL_KEY, description("Log level [OFF, ALL, ERROR, WARN, INFO, DEBUG, TRACE]", LOG_LEVEL_DEFAULT))
|
||||
.withRequiredArg();
|
||||
parser.accepts(ProgramArguments.NAME_KEY, description("Name of this node", null))
|
||||
.withRequiredArg();
|
||||
// use a fixed port as arbitrator use that for his ID
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.bitsquare.p2p.seed;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import io.bitsquare.app.Log;
|
||||
import io.bitsquare.app.Version;
|
||||
@ -9,7 +10,6 @@ import io.bitsquare.common.util.Utilities;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
import io.bitsquare.p2p.P2PServiceListener;
|
||||
import io.bitsquare.p2p.peers.PeerManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -124,7 +124,7 @@ public class SeedNode {
|
||||
log.info("Log files under: " + logPath);
|
||||
Version.printVersion();
|
||||
Utilities.printSysInfo();
|
||||
Log.setLevel(useDetailedLogging);
|
||||
Log.setLevel(Level.WARN);
|
||||
|
||||
SeedNodesRepository seedNodesRepository = new SeedNodesRepository();
|
||||
if (progArgSeedNodes != null && !progArgSeedNodes.isEmpty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user