当前位置: 首页>>代码示例>>Java>>正文


Java MessageFormatter类代码示例

本文整理汇总了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();
}
 
开发者ID:xxlabaza,项目名称:ping,代码行数:14,代码来源:I18nMessageConverter.java

示例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();
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:22,代码来源:StormRecorder.java

示例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;
   }
 
开发者ID:ilivoo,项目名称:game,代码行数:26,代码来源:CacheEngineImpl.java

示例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);
}
   }
 
开发者ID:ilivoo,项目名称:game,代码行数:20,代码来源:CacheManager.java

示例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;
   }
 
开发者ID:ilivoo,项目名称:game,代码行数:17,代码来源:NioServerBeanDefinitionParser.java

示例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;
   }
 
开发者ID:ilivoo,项目名称:game,代码行数:18,代码来源:ExcelReader.java

示例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);
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:21,代码来源:MatchProcessLogServiceImpl.java

示例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;
   }
 
开发者ID:ilivoo,项目名称:game,代码行数:24,代码来源:Storage.java

示例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;
   }
 
开发者ID:ilivoo,项目名称:game,代码行数:23,代码来源:Storage.java

示例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);
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:23,代码来源:MatchProcessLogger.java

示例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());
    }
}
 
开发者ID:kwon37xi,项目名称:slf4j-lambda,代码行数:14,代码来源:LambdaLoggerPlainImpl.java

示例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 );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:9,代码来源:AuditLogServiceImpl.java

示例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());
}
 
开发者ID:Esri,项目名称:server-extension-java,代码行数:15,代码来源:LogAdaptor.java

示例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();
    });
}
 
开发者ID:Atypon-OpenSource,项目名称:wayf-cloud,代码行数:14,代码来源:FacadePolicies.java

示例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();
}
   }
 
开发者ID:ilivoo,项目名称:game,代码行数:15,代码来源:PersisterService.java


注:本文中的org.slf4j.helpers.MessageFormatter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。