Skip to content

Commit 287ef6e

Browse files
author
gitlab
committed
Merge branch 'log' into 'master'
Log See merge request zstackio/zstack!2403
2 parents 779f337 + 3ff4a7b commit 287ef6e

10 files changed

Lines changed: 52 additions & 16 deletions

File tree

conf/zstack.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ DbFacadeDataSource.testConnectionOnCheckout = true
2727
consoleProxyOverriddenIp =
2828
consoleProxyPort=4900
2929

30+
sns.systemTopic.endpoints.http.url=http://localhost:5000/zwatch/webhook
31+
3032
# Default API timeout settings
3133
#
3234
#ApiTimeout.org.zstack.header.image.APIAddImageMsg = timeout::3h

core/src/main/java/org/zstack/core/Platform.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ private static void linkGlobalProperty(Class clz, Map<String, String> properties
165165
try {
166166
f.set(null, valueToSet);
167167
globalProperties.put(name, valueToSet == null ? "null" : valueToSet.toString());
168-
logger.debug(String.format("linked global property[%s.%s], value: %s", clz.getName(), f.getName(), valueToSet));
168+
if (logger.isTraceEnabled()) {
169+
logger.trace(String.format("linked global property[%s.%s], value: %s", clz.getName(), f.getName(), valueToSet));
170+
}
169171
} catch (IllegalAccessException e) {
170172
throw new CloudRuntimeException(String.format("unable to link global property[%s.%s]", clz.getName(), f.getName()), e);
171173
}

core/src/main/java/org/zstack/core/cascade/CascadeFacadeImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,11 @@ private TreeNode createTraversingTree(String issuer) {
388388
ret.add(spath);
389389
}
390390

391-
logger.debug(String.format("Cascade operation[%s]'s traversing branches (branches will be merged as a tree to reduce duplicate paths):", issuer));
392-
for (List<String> lst : ret) {
393-
logger.debug(lst.toString());
391+
if (logger.isTraceEnabled()) {
392+
logger.trace(String.format("Cascade operation[%s]'s traversing branches (branches will be merged as a tree to reduce duplicate paths):", issuer));
393+
for (List<String> lst : ret) {
394+
logger.trace(lst.toString());
395+
}
394396
}
395397

396398
return makeTree(paths);

core/src/main/java/org/zstack/core/cloudbus/CloudBusGlobalProperty.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class CloudBusGlobalProperty {
1919
public static boolean MESSAGE_LOG_FILTER_ALL;
2020
@GlobalProperty(name="CloudBus.messageLog")
2121
public static String MESSAGE_LOG;
22+
@GlobalProperty(name="CloudBus.readAPILogOff", defaultValue = "true")
23+
public static boolean READ_API_LOG_OFF;
2224
@GlobalProperty(name="CloudBus.rabbitmqUsername")
2325
public static String RABBITMQ_USERNAME;
2426
@GlobalProperty(name="CloudBus.rabbitmqPassword")

core/src/main/java/org/zstack/core/cloudbus/CloudBusImpl2.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ public void send(Message msg) {
533533
}
534534

535535
public boolean logMessage(Message msg) {
536+
if (CloudBusGlobalProperty.READ_API_LOG_OFF &&
537+
(msg instanceof APISyncCallMessage || msg instanceof APIReply)) {
538+
return false;
539+
}
540+
536541
if (CloudBusGlobalProperty.MESSAGE_LOG_FILTER_ALL) {
537542
return !filterMsgNames.contains(msg.getClass().getName());
538543
} else {
@@ -898,7 +903,11 @@ void trackService(String servId) {
898903
String bindingKey = makeMessageQueueName(StringUtils.join(pairs, "."));
899904

900905
bindingKeys.add(bindingKey);
901-
logger.debug(String.format("message tracker binds to key[%s], tracking service[%s]", bindingKey, pairs[0]));
906+
907+
if (logger.isTraceEnabled()) {
908+
logger.trace(String.format("message tracker binds to key[%s], tracking service[%s]", bindingKey, pairs[0]));
909+
}
910+
902911
try {
903912
Channel chan = channelPool.acquire();
904913
try {

core/src/main/java/org/zstack/core/componentloader/PluginDefinitionParser.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder holder, Par
9090
Map<String, List<PluginExtension>> extensions = new HashMap<String, List<PluginExtension>>(1);
9191
extensions.put(ext.getBeanClassName(), exts);
9292
prop = new PropertyValue(PluginRegistry.PLUGIN_REGISTRYIMPL_PLUGINS_FIELD_NAME, extensions);
93-
logger.debug("No 'extensions' property found in PluginRegistry bean definition, create a new one");
93+
if (logger.isTraceEnabled()) {
94+
logger.trace("No 'extensions' property found in PluginRegistry bean definition, create a new one");
95+
}
9496
props.addPropertyValue(prop);
9597
} else {
9698
Map<String, List<PluginExtension>> extensions = (Map<String, List<PluginExtension>>) prop.getValue();
9799
List<PluginExtension> oexts = extensions.get(ext.getBeanClassName());
98100
if (oexts == null) {
99-
oexts = new ArrayList<PluginExtension>(exts.size());
101+
oexts = new ArrayList<>(exts.size());
100102
extensions.put(ext.getBeanClassName(), oexts);
101103
}
102104

@@ -108,8 +110,10 @@ public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder holder, Par
108110

109111
oexts.addAll(exts);
110112
}
111-
112-
logger.debug(String.format("Add extensions declared by bean[name=%s, class=%s] to 'extensions' property of PluginRegistry bean definition", ext.getBeanName(), ext.getBeanClassName()));
113+
114+
if (logger.isTraceEnabled()) {
115+
logger.trace(String.format("Add extensions declared by bean[name=%s, class=%s] to 'extensions' property of PluginRegistry bean definition", ext.getBeanName(), ext.getBeanClassName()));
116+
}
113117
}
114118

115119
return holder;

core/src/main/java/org/zstack/core/config/GlobalConfigFacadeImpl.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ private void persistConfigInXmlButNotInDatabase() {
270270
continue;
271271
}
272272

273-
logger.debug(String.format("Add a new global config to database: %s", config.toString()));
273+
if (logger.isTraceEnabled()) {
274+
logger.trace(String.format("Add a new global config to database: %s", config.toString()));
275+
}
276+
274277
toSave.add(config.toVO());
275278
}
276279

@@ -554,8 +557,10 @@ public void validateGlobalConfig(String category, String name, String oldValue,
554557

555558
config.setConfigDef(field.getAnnotation(GlobalConfigDef.class));
556559
config.setLinked(true);
557-
logger.debug(String.format("linked GlobalConfig[category:%s, name:%s, value:%s] to %s.%s",
558-
config.getCategory(), config.getName(), config.getDefaultValue(), field.getDeclaringClass().getName(), field.getName()));
560+
if (logger.isTraceEnabled()) {
561+
logger.trace(String.format("linked GlobalConfig[category:%s, name:%s, value:%s] to %s.%s",
562+
config.getCategory(), config.getName(), config.getDefaultValue(), field.getDeclaringClass().getName(), field.getName()));
563+
}
559564
}
560565
}
561566

core/src/main/java/org/zstack/core/db/DatabaseFacadeImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,9 @@ private void buildEntityInfo() {
778778
String[] pkgs = StringUtils.split(DbGlobalProperty.ENTITY_PACKAGES, ",");
779779
List<Class> clzs = BeanUtils.scanClass(Arrays.asList(pkgs), Entity.class);
780780
for (Class clz : clzs) {
781-
logger.debug(String.format("build entity info for %s", clz.getName()));
781+
if (logger.isTraceEnabled()) {
782+
logger.trace(String.format("build entity info for %s", clz.getName()));
783+
}
782784
entityInfoMap.put(clz, new EntityInfo(clz));
783785
}
784786
}

portal/src/main/java/org/zstack/portal/apimediator/ApiMessageProcessorImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ private void prepareInterceptors(ApiMessageDescriptor desc, Service.Message msch
151151
List<GlobalApiMessageInterceptor> end = new ArrayList<GlobalApiMessageInterceptor>();
152152

153153
for (GlobalApiMessageInterceptor gi : gis) {
154-
logger.debug(String.format("install GlobalApiMessageInterceptor[%s] to message[%s]", gi.getClass().getName(), desc.getClazz().getName()));
154+
if (logger.isTraceEnabled()) {
155+
logger.trace(String.format("install GlobalApiMessageInterceptor[%s] to message[%s]", gi.getClass().getName(), desc.getClazz().getName()));
156+
}
157+
155158
if (gi.getPosition() == InterceptorPosition.FRONT) {
156159
front.add(gi);
157160
} else if (gi.getPosition() == InterceptorPosition.END){
@@ -162,7 +165,10 @@ private void prepareInterceptors(ApiMessageDescriptor desc, Service.Message msch
162165
}
163166

164167
for (GlobalApiMessageInterceptor gi : globalInterceptorsForAllMsg) {
165-
logger.debug(String.format("install GlobalApiMessageInterceptor[%s] to message[%s]", gi.getClass().getName(), desc.getClazz().getName()));
168+
if (logger.isTraceEnabled()) {
169+
logger.trace(String.format("install GlobalApiMessageInterceptor[%s] to message[%s]", gi.getClass().getName(), desc.getClazz().getName()));
170+
}
171+
166172
if (gi.getPosition() == GlobalApiMessageInterceptor.InterceptorPosition.FRONT) {
167173
front.add(gi);
168174
} else if (gi.getPosition() == InterceptorPosition.END){

tag/src/main/java/org/zstack/tag/TagManagerImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ void init() {
117117
Class type = entity.getJavaType();
118118
String name = type.getSimpleName();
119119
resourceTypeClassMap.put(name, type);
120-
logger.debug(String.format("discovered tag resource type[%s], class[%s]", name, type));
120+
if (logger.isTraceEnabled()) {
121+
logger.trace(String.format("discovered tag resource type[%s], class[%s]", name, type));
122+
}
121123
}
122124

123125
try {

0 commit comments

Comments
 (0)