Skip to content

Commit 478836a

Browse files
committed
fix logging issues
1 parent 473884b commit 478836a

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/main/java/picoded/dstack/mongodb/MongoDBStack.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ public static String getFullConnectionURL_primary(GenericConvertMap<String, Obje
110110
int port = config.getInt("port", 27017);
111111

112112
// Safety check
113-
if( host == null ) {
113+
if (host == null || host.isEmpty()) {
114114
throw new IllegalArgumentException("Missing valid host setting for MongoDB connection");
115115
}
116-
116+
117117
// Hanlding of option string
118118
GenericConvertMap<String, Object> optMap = config.getGenericConvertStringMap("opt",
119119
defaultOptJson);

src/main/java/picoded/dstack/stack/ProviderConfig.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import java.util.List;
55
import java.util.Map;
66
import java.util.concurrent.ConcurrentHashMap;
7+
import java.util.logging.Level;
8+
import java.util.logging.Logger;
79

8-
import io.vertx.core.impl.logging.Logger;
910
import picoded.core.conv.ConvertJSON;
1011
import picoded.core.struct.GenericConvertHashMap;
1112
import picoded.core.struct.GenericConvertList;
@@ -147,25 +148,27 @@ public CoreStack getProviderStack(String name) {
147148
return cache;
148149
}
149150

150-
// Log the setup
151-
String type = providerConfig.getString("type");
152-
LOGGER.info("Setting DStack provider backend : "+name+" ("+type+")");
153-
154151
// Cache not found, get config to initialize a new stack
155152
GenericConvertMap<String, Object> providerConfig = getStackConfig(name);
156153
if (providerConfig == null) {
154+
LOGGER.log(Level.SEVERE, "Unknown provider name, config not found : " + name);
157155
throw new IllegalArgumentException("Unknown provider name, config not found : " + name);
158156
}
159157

158+
// Log the setup
159+
String type = providerConfig.getString("type");
160+
LOGGER.info("Setting DStack provider backend : " + name + " (" + type + ")");
161+
160162
// Initialization of stack and store into cache
161163
try {
162164
cache = initStack(type, providerConfig);
163-
} catch(Exception e) {
165+
} catch (Exception e) {
164166
// Log the error, as this is easily missed into an API error
165-
LOGGER.error("Error while setting DStack provider : "+name+" ("+type+")", e);
167+
LOGGER.log(Level.SEVERE, "Error while setting DStack provider : " + name + " (" + type
168+
+ ")", e);
166169
throw new RuntimeException(e);
167170
}
168-
171+
169172
// Save it into cache
170173
providerStackMap.put(name, cache);
171174

0 commit comments

Comments
 (0)