本文整理匯總了Java中org.slf4j.helpers.MessageFormatter類的典型用法代碼示例。如果您正苦於以下問題:Java MessageFormatter類的具體用法?Java MessageFormatter怎麽用?Java MessageFormatter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MessageFormatter類屬於org.slf4j.helpers包,在下文中一共展示了MessageFormatter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convert
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
@Override
public String convert (ILoggingEvent event) {
val key = event.getMessage();
if (!BUNDLE.containsKey(key)) {
return event.getFormattedMessage();
}
val messagePattern = BUNDLE.getString(key);
val argumentArray = event.getArgumentArray();
return MessageFormatter
.arrayFormat(messagePattern, argumentArray)
.getMessage();
}
示例2: generateKey
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
/**
* Internal utility class to help generate metric keys.
*
* @return in format of: "className.metricPrefix.metricName"
*/
private String generateKey(final MetricDefinition metric, final Object[] parameters) {
final StringBuilder keyBuilder = new StringBuilder();
// Conditionally add key prefix.
if (getMetricPrefix() != null && !getMetricPrefix().isEmpty()) {
keyBuilder
.append(getMetricPrefix())
.append(".");
}
// Our default implementation should include the simple class name in the key
keyBuilder.append(
MessageFormatter.format(metric.getKey(), parameters).getMessage()
);
return keyBuilder.toString();
}
示例3: unique
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
@Override
public T unique(String indexName, Object indexValue) {
ConcurrentMap<Object, PK> indexMap = uniqueCacheMap.get(indexName);
if (indexMap == null) {
String message = MessageFormatter
.format("實體[{}]不存在唯一索引[{}]", cacheDefinition.getClz().getSimpleName(), indexName).getMessage();
log.error(message);
return null;
}
PK id = indexMap.get(indexValue);
if (id != null) {
return load(id);
}
Lock lock = getPKLocked(id);
try {
id = indexMap.get(indexValue);
if (id != null) {
return load(id);
}
idLocks.remove(id);
} finally {
lock.unlock();
}
return null;
}
示例4: postConstruct
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
@PostConstruct
void postConstruct() {
init();
cacheThreadCount = cacheThreadCount == 0 ? DEFAULT_CACHE_THREAD_COUNT : cacheThreadCount;
executor = Executors.newScheduledThreadPool(cacheThreadCount,
new CustomizableThreadFactory("Recache-Cache-Thread-"));
for (CacheDefinition<?> definition : cacheDefinitions.values()) {
try {
definition.setEnhanceClz(EnhanceUtil.createEnhanceEntity(definition));
} catch (Exception e) {
String message = MessageFormatter.format("創建[{}]類的增強類出現異常", definition.getClz()).getMessage();
log.error(message, e);
throw new RuntimeException(message, e);
}
CacheEngineImpl cacheEngineImpl = new CacheEngineImpl(accessor, definition, persisterService, executor);
cacheEngines.put(definition.getClz(), cacheEngineImpl);
}
}
示例5: checkAndFindFileUrl
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
public String checkAndFindFileUrl(Class<?> clz, List<String> dynamicSource) {
String result = null;
for (String absFileNames : dynamicSource) {
File file = new File(absFileNames);
if (StringUtils.stripFilenameExtension(file.getName()).equals(clz.getSimpleName())) {
result = absFileNames;
}
}
if (result == null) {
String message = MessageFormatter.format("無法找到動態Bean[{}]對應的源文件", clz).getMessage();
log.error(message);
throw new RuntimeException(message);
}
dynamicSource.remove(result);
return "file:" + result;
}
示例6: getInterestServerRowDetail
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
private Map<Integer, String> getInterestServerRowDetail(Row row, Class<?> clz) {
Map<Integer, String> interestServerRowDetail = new LinkedHashMap<Integer, String>();
Map<Integer, String> serverRowDetail = getServerRowDetail(row);
for (Entry<Integer, String> entry : serverRowDetail.entrySet()) {
if (ReflectionUtils.findField(clz, entry.getValue()) == null) {
if (getDebug().isIgnoreAbsent()) {
continue;
}
String message = MessageFormatter.format("[{}]對應的資源中存在多餘的[{}]屬性", clz.getName(), entry.getValue())
.getMessage();
log.error(message);
throw new ResourceFormatException(message);
}
interestServerRowDetail.put(entry.getKey(), entry.getValue());
}
return interestServerRowDetail;
}
示例7: log
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
public void log(String messageId, Object[] args, boolean status, UUID housingUnitId, UUID projectId,
UUID clientId) {
FormattingTuple tp = null;
try {
tp = MessageFormatter.arrayFormat(env.getProperty(messageId), args);
} catch (Exception e) {
tp = MessageFormatter.arrayFormat("Message foormat tewst {} with tuple {}", new Object[] { "param1" });
}
MatchProcessLogEntity entity = new MatchProcessLogEntity();
entity.setClientId(clientId);
entity.setHousingUnitId(housingUnitId);
entity.setProjectId(projectId);
entity.setStatus(status);
entity.setStatusMessage(tp.getMessage());
entity.setProcessId(this.processId);
logRepository.save(entity);
}
示例8: getValue
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
/**
* 獲取到id對應的值
*
* @param k
* @return
*/
public V getValue(K k, boolean isThrow) {
Assert.notNull(k);
V v = null;
readLock.lock();
try {
v = values.get(k);
if (v == null && isThrow) {
String message = MessageFormatter
.format("無法找到[{}]中id為[{}]對應的資源", resourceDefinition.getClz().getSimpleName(), k).getMessage();
log.error(message);
throw new RuntimeException(message);
}
} finally {
readLock.unlock();
}
return v;
}
示例9: getValues
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
public List<V> getValues(List<K> ks, boolean isThrow) {
Assert.notNull(ks);
List<V> vs = new ArrayList<V>();
readLock.lock();
try {
for (K k : ks) {
V v = values.get(k);
if (v == null && isThrow) {
String message = MessageFormatter
.format("無法找到[{}]中id為[{}]對應的資源", resourceDefinition.getClz().getSimpleName(), k)
.getMessage();
log.error(message);
throw new RuntimeException(message);
} else {
vs.add(v);
}
}
} finally {
readLock.unlock();
}
return vs;
}
示例10: log
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
public void log(String messageId, Object[] args, boolean status, UUID housingUnitId, UUID projectId,
UUID clientId) {
FormattingTuple tp = null;
try {
tp = MessageFormatter.arrayFormat(env.getProperty(messageId), args);
System.out.println(" Message "+messageId+" test message "+tp.getMessage()+" test");
if(env.getProperty(messageId).isEmpty()) System.out.println("Empty property");
} catch (Exception e) {
System.out.println("Exception message property "+messageId);
tp = MessageFormatter.arrayFormat("Message foormat tewst {} with tuple {}", new Object[] { "param1" });
}
MatchProcessLogEntity entity = new MatchProcessLogEntity();
entity.setClientId(clientId);
entity.setHousingUnitId(housingUnitId);
entity.setProjectId(projectId);
entity.setStatus(status);
entity.setStatusMessage(tp.getMessage());
entity.setProcessId(this.processId);
logRepository.save(entity);
}
示例11: doLog
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
@Override
public void doLog(Marker marker, Level level, String format, Supplier<?>[] argSuppliers, Throwable t) {
if (!LambdaLoggerUtils.isLogLevelEnabled(underlyingLogger, level, marker)) {
return;
}
if (argSuppliers == null) {
logFormatted(marker, level, format, t);
} else {
FormattingTuple formattingTuple = MessageFormatter.arrayFormat(format, argSuppliersToArgs(argSuppliers), t);
logFormatted(marker, level, formattingTuple.getMessage(), formattingTuple.getThrowable());
}
}
示例12: debug
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
@Override
public void debug ( final String message, final Object... arguments )
{
if ( Boolean.getBoolean ( PROP_ENABLE_DEBUG ) )
{
log ( Severity.INFORMATION, MessageFormatter.arrayFormat ( message, arguments ).getMessage (), null );
}
}
示例13: formatAndLog
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
/**
* For formatted messages, first substitute arguments and then log.
*
* @param level
* @param format
* @param arguments a list of 3 ore more arguments
*/
private void formatAndLog(int level, String format, Object... arguments) {
if (!isLevelEnabled(level)) {
return;
}
FormattingTuple tp = MessageFormatter.arrayFormat(format, arguments);
log(level, tp.getMessage(), tp.getThrowable());
}
示例14: singleOrException
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
public static final <T> Single<T> singleOrException(Maybe<T> maybe, int statusCode, String message, Object... args) {
Single<Boolean> isEmpty = maybe.isEmpty();
return isEmpty.flatMap((_isEmpty) -> {
if (_isEmpty) {
FormattingTuple formattedMessage = MessageFormatter.arrayFormat(message, args);
throw new ServiceException(statusCode, formattedMessage.getMessage());
}
return maybe.toSingle();
});
}
示例15: save
import org.slf4j.helpers.MessageFormatter; //導入依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
private void save(Class clz, Entity entity, PersisterListener listner) {
try {
listner.before();
accessor.save(clz, entity);
listner.success();
} catch (Exception e) {
String message = MessageFormatter
.arrayFormat("保存[{}]類型的實體對象[{}]出現錯誤", new Object[] { clz.getName(), entity.getId(), e })
.getMessage();
log.error(message, e);
listner.exception();
}
}