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


Java ExtLogRecord.setMessage方法代码示例

本文整理汇总了Java中org.jboss.logmanager.ExtLogRecord.setMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ExtLogRecord.setMessage方法的具体用法?Java ExtLogRecord.setMessage怎么用?Java ExtLogRecord.setMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.logmanager.ExtLogRecord的用法示例。


在下文中一共展示了ExtLogRecord.setMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: formatExtRecord

import org.jboss.logmanager.ExtLogRecord; //导入方法依赖的package包/类
private String formatExtRecord(final ExtLogRecord record) {
  String format = getMessageFormat(record);
  if (format == null) {
    return super.formatMessage(record);
  }
  Object[] parameters = record.getParameters();
  String msg;
  switch (record.getFormatStyle()) {
  case MESSAGE_FORMAT:
    msg = format.indexOf("{0") >= 0 ? MessageFormat.format(format, parameters) : format;
    break;
  case PRINTF:
    msg = (parameters == null) ? String.format(format) : String.format(format, parameters);
    break;
  case NO_FORMAT:
  default:
    msg = format;
    break;
  }
  record.setParameters(null);
  record.setMessage(msg);
  return super.formatMessage(record);
}
 
开发者ID:kifj,项目名称:wildfly-logstash,代码行数:24,代码来源:LogstashUtilFormatter.java

示例2: testSeveralLogEntries

import org.jboss.logmanager.ExtLogRecord; //导入方法依赖的package包/类
@Test
public void testSeveralLogEntries() throws Throwable {
	LogstashFormatter formatter = new LogstashFormatter(
			createBasicLogstashFactory());

	ExtLogRecord logRecord1 = this.createBasicLogRecord();
	logRecord1.setMessage("My message1");
	String currentResult1 = formatter.format(logRecord1);
	String expectedResult1 = "{\"host\":\"myHost\",\"level\": \"INFO\",\"@timestamp\":\"2001-11-09T01:46:40.123Z\",\"message\":\"My message1\",\"thread\": \"main\",\"classname\": \"net.logstash.loggers.logstash_jboss_logmanager.test\"}";
	JSONAssert.assertEquals(expectedResult1, currentResult1, true);

	ExtLogRecord logRecord2 = this.createBasicLogRecord();
	logRecord2.setMessage("My message2");
	String currentResult2 = formatter.format(logRecord2);
	String expectedResult2 = "{\"host\":\"myHost\",\"level\": \"INFO\",\"@timestamp\":\"2001-11-09T01:46:40.123Z\",\"message\":\"My message2\",\"thread\": \"main\",\"classname\": \"net.logstash.loggers.logstash_jboss_logmanager.test\"}";
	JSONAssert.assertEquals(expectedResult2, currentResult2, true);
}
 
开发者ID:mpucholblasco,项目名称:logstash-loggers,代码行数:18,代码来源:LogstashFormatterTest.java

示例3: testMessageStrangeCharacters

import org.jboss.logmanager.ExtLogRecord; //导入方法依赖的package包/类
@Test
public void testMessageStrangeCharacters() throws Throwable {
	ExtLogRecord logRecord = this.createBasicLogRecord();
	logRecord.setMessage("My message: áéíóúÀÈÌÒÙ€");
	LogstashFormatter formatter = new LogstashFormatter(
			createBasicLogstashFactory());
	String currentResult = formatter.format(logRecord);
	String expectedResult = "{\"host\":\"myHost\",\"level\": \"INFO\",\"@timestamp\":\"2001-11-09T01:46:40.123Z\",\"message\":\"My message: áéíóúÀÈÌÒÙ€\",\"thread\": \"main\",\"classname\": \"net.logstash.loggers.logstash_jboss_logmanager.test\"}";
	JSONAssert.assertEquals(expectedResult, currentResult, true);
}
 
开发者ID:mpucholblasco,项目名称:logstash-loggers,代码行数:11,代码来源:LogstashFormatterTest.java

示例4: testMessageWithQuotes

import org.jboss.logmanager.ExtLogRecord; //导入方法依赖的package包/类
@Test
public void testMessageWithQuotes() throws Throwable {
	ExtLogRecord logRecord = this.createBasicLogRecord();
	logRecord
			.setMessage("My message with quotes: \"double quotes\", 'single quotes'");
	LogstashFormatter formatter = new LogstashFormatter(
			createBasicLogstashFactory());
	String currentResult = formatter.format(logRecord);
	String expectedResult = "{\"host\":\"myHost\",\"level\": \"INFO\",\"@timestamp\":\"2001-11-09T01:46:40.123Z\",\"message\":\"My message with quotes: \\\"double quotes\\\", 'single quotes'\",\"thread\": \"main\",\"classname\": \"net.logstash.loggers.logstash_jboss_logmanager.test\"}";
	JSONAssert.assertEquals(expectedResult, currentResult, true);
}
 
开发者ID:mpucholblasco,项目名称:logstash-loggers,代码行数:12,代码来源:LogstashFormatterTest.java

示例5: testMessageWithCarriageReturn

import org.jboss.logmanager.ExtLogRecord; //导入方法依赖的package包/类
@Test
public void testMessageWithCarriageReturn() throws Throwable {
	ExtLogRecord logRecord = this.createBasicLogRecord();
	logRecord.setMessage("My multiline message.\nLine 2\nLine 3");
	LogstashFormatter formatter = new LogstashFormatter(
			createBasicLogstashFactory());
	String currentResult = formatter.format(logRecord);
	String expectedResult = "{\"host\":\"myHost\",\"level\": \"INFO\",\"@timestamp\":\"2001-11-09T01:46:40.123Z\",\"message\":\"My multiline message.\\nLine 2\\nLine 3\",\"thread\": \"main\",\"classname\": \"net.logstash.loggers.logstash_jboss_logmanager.test\"}";
	JSONAssert.assertEquals(expectedResult, currentResult, true);
}
 
开发者ID:mpucholblasco,项目名称:logstash-loggers,代码行数:11,代码来源:LogstashFormatterTest.java


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