com.nepxion.discovery.plugin.configcenter.logger.ConfigLogger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-plugin-config-center-starter Show documentation
Show all versions of discovery-plugin-config-center-starter Show documentation
Nepxion Discovery is a solution for Spring Cloud with blue green, gray, weight, limitation, circuit breaker, degrade, isolation, monitor, tracing, dye, failover, async agent
The newest version!
package com.nepxion.discovery.plugin.configcenter.logger;
/**
* Title: Nepxion Discovery
* Description: Nepxion Discovery
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.discovery.common.entity.ConfigType;
import com.nepxion.discovery.common.entity.SubscriptionType;
import com.nepxion.discovery.plugin.configcenter.adapter.ConfigAdapter;
public class ConfigLogger {
private static final Logger LOG = LoggerFactory.getLogger(ConfigLogger.class);
@Autowired(required = false)
private ConfigAdapter configAdapter;
public void logGetStarted(boolean globalConfig) {
if (configAdapter == null) {
return;
}
String group = configAdapter.getGroup();
String dataId = configAdapter.getDataId(globalConfig);
SubscriptionType subscriptionType = configAdapter.getSubscriptionType(globalConfig);
ConfigType configType = configAdapter.getConfigType();
LOG.info("Get {} config from {} server, " + getLogKey(), subscriptionType, configType, group, dataId);
}
public void logSubscribeStarted(boolean globalConfig) {
if (configAdapter == null) {
return;
}
String group = configAdapter.getGroup();
String dataId = configAdapter.getDataId(globalConfig);
SubscriptionType subscriptionType = configAdapter.getSubscriptionType(globalConfig);
ConfigType configType = configAdapter.getConfigType();
LOG.info("Subscribe {} config from {} server, " + getLogKey(), subscriptionType, configType, group, dataId);
}
public void logSubscribeFailed(Exception e, boolean globalConfig) {
if (configAdapter == null) {
return;
}
String group = configAdapter.getGroup();
String dataId = configAdapter.getDataId(globalConfig);
SubscriptionType subscriptionType = configAdapter.getSubscriptionType(globalConfig);
ConfigType configType = configAdapter.getConfigType();
LOG.error("Subscribe {} config from {} server failed, " + getLogKey(), subscriptionType, configType, group, dataId, e);
}
public void logUnsubscribeStarted(boolean globalConfig) {
if (configAdapter == null) {
return;
}
String group = configAdapter.getGroup();
String dataId = configAdapter.getDataId(globalConfig);
SubscriptionType subscriptionType = configAdapter.getSubscriptionType(globalConfig);
ConfigType configType = configAdapter.getConfigType();
LOG.info("Unsubscribe {} config from {} server, " + getLogKey(), subscriptionType, configType, group, dataId);
}
public void logUnsubscribeFailed(Exception e, boolean globalConfig) {
if (configAdapter == null) {
return;
}
String group = configAdapter.getGroup();
String dataId = configAdapter.getDataId(globalConfig);
SubscriptionType subscriptionType = configAdapter.getSubscriptionType(globalConfig);
ConfigType configType = configAdapter.getConfigType();
LOG.error("Unsubscribe {} config from {} server failed, " + getLogKey(), subscriptionType, configType, group, dataId, e);
}
public void logFound(boolean globalConfig) {
if (configAdapter == null) {
return;
}
SubscriptionType subscriptionType = configAdapter.getSubscriptionType(globalConfig);
ConfigType configType = configAdapter.getConfigType();
LOG.info("Found {} config from {} server", subscriptionType, configType);
}
public void logNotFound(boolean globalConfig) {
if (configAdapter == null) {
return;
}
SubscriptionType subscriptionType = configAdapter.getSubscriptionType(globalConfig);
ConfigType configType = configAdapter.getConfigType();
LOG.info("Not found {} config from {} server", subscriptionType, configType);
}
public void logUpdatedEvent(boolean globalConfig) {
if (configAdapter == null) {
return;
}
String group = configAdapter.getGroup();
String dataId = configAdapter.getDataId(globalConfig);
SubscriptionType subscriptionType = configAdapter.getSubscriptionType(globalConfig);
ConfigType configType = configAdapter.getConfigType();
LOG.info("Get {} config updated event from {} server, " + getLogKey(), subscriptionType, configType, group, dataId);
}
public void logClearedEvent(boolean globalConfig) {
if (configAdapter == null) {
return;
}
String group = configAdapter.getGroup();
String dataId = configAdapter.getDataId(globalConfig);
SubscriptionType subscriptionType = configAdapter.getSubscriptionType(globalConfig);
ConfigType configType = configAdapter.getConfigType();
LOG.info("Get {} config cleared event from {} server, " + getLogKey(), subscriptionType, configType, group, dataId);
}
public void logUpdatedSame(boolean globalConfig) {
if (configAdapter == null) {
return;
}
String group = configAdapter.getGroup();
String dataId = configAdapter.getDataId(globalConfig);
SubscriptionType subscriptionType = configAdapter.getSubscriptionType(globalConfig);
ConfigType configType = configAdapter.getConfigType();
LOG.info("Updated {} config from {} server is same as current config, ignore to update, " + getLogKey(), subscriptionType, configType, group, dataId);
}
private String getLogKey() {
if (configAdapter == null) {
return null;
}
return configAdapter.isConfigSingleKey() ? "key={}-{}" : "group={}, dataId={}";
}
}